Mental Model
The diameter of a tree is the longest path between any two nodes. We find it by exploring the longest paths from each node using dynamic programming.
Analogy: Imagine a network of roads connecting towns. The diameter is the longest route you can travel without repeating towns. We find it by checking the longest roads from each town and combining them.
1
/ \
2 3
/ \
4 5
Nodes connected like a tree with branches.