Problem. Return the length of the longest path between any two nodes, counted in edges. The path may or may not pass through the root.
1
/ \ → 3 (4 → 2 → 1 → 3, or 5 → 2 → 1 → 3)
2 3
/ \
4 5
The new idea compared with lesson 10.2: the function returns one thing to its parent (the height) but computes another along the way (the best path seen so far). Many hard tree problems have this shape: lesson 10.13's maximum path sum is the same pattern with values instead of counts.
ML context. In a tree of dependent tasks (a preprocessing pipeline that fans out, a hierarchical evaluation suite, a tree-shaped computation where children must finish before parents), the longest weighted path is the critical path: the minimum wall-clock time even with unlimited parallel workers (Change D).