dfs
that takes the current node, the current path, and the remaining sum as arguments.null
, return immediately as this is not a valid path.dfs
on the left and right children of the current node, passing the updated path and remaining sum.dfs
with the root node, an empty path, and the target sum to start the DFS traversal.