Sponsored
Use these hints if you're stuck. Try solving on your own first.
Convert the tree to a general graph, and do a breadth-first search. Alternatively, find the closest leaf for every node on the path from root to target.
Solve with full IDE support and test cases