Input: root = [1,2,3,4,5]
Explanation: The path [4,2,1,3] or [5,2,1,3] has a length of 3 edges. Node 1 is the root, 2 is its left child, 3 is its right child. 4 and 5 are children of 2.
The diameter passes through node 2 (not necessarily the root 1) with paths from 4 to 1 to 3 being 3 edges, or 5 to 1 to 3 being 3 edges.
More precisely, the path [4,2,5] is 2 edges, and [4,2,1,3] is 3 edges. The path [5,2,1,3] is also 3 edges. The longest path is 3.