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