Function for getting the centermost node of a tree