Add max distance in bst problem