Diameter is equal to the path between the two farthest nodes leaf1 and leaf2
getDiameterPath ( leaf1 , leaf2 , - 1 , path ) ; int pathSize = path . size ( ) ; if ( pathSize % 2 == 1 ) { System . out . println ( path . get ( pathSize / 2 ) ) ; } else { System . out . println ( path . get ( pathSize / 2 ) + " , ▁ " + path . get ( ( pathSize - 1 ) / 2 ) ) ; } }