public static < T extends TreeNode < T > > T getRoot ( T node ) { if ( node == null ) return null ; if ( node . getParent ( ) != null ) return getRoot ( node . getParent ( ) ) ; return node ; }
Returns the root of the tree the given node is part of .