dfs
that takes a node and the remaining limit as arguments.null
, return null
.dfs
on the left and right children, subtracting the node's value from the limit.null
, it means that all paths from this node are insufficient, so return null
.dfs
with the root node and the initial limit.dfs
call as the new root of the pruned tree.