Tree: edges (,), (,), (,), (,). BFS from gives farthest nodes and (distance ). Pick .
BFS from gives farthest node (distance ). BFS from gives distances {:, :, :, :, :}.
From endpoint : distances {:, :, :, :, :}. From endpoint : distances {:, :, :, :, :}.
For node : max(dist from , dist from ) = max(, ) = . That is node 's answer.