add maxDistance

add a function to get the max distance between any two nodes of the tree