Considering the Tree as binary
/ / \
d e f
/ \ \
g h p
The longest leaf to leaf path would be k-h-d-b-a-c-f-p i.e of length 8.
- Calculate the diameter at each node (assuming node as a root of the tree)
- Diameter is the height of left subtree + height of right subtree + 1.
- Pick the highest diameter amongst all.