public Parse getCommonParent ( Parse node ) { if ( this == node ) { return parent ; } Set parents = new HashSet ( ) ; Parse cparent = this ; while ( cparent != null ) { parents . add ( cparent ) ; cparent = cparent . getParent ( ) ; } while ( node != null ) { if ( parents . contains ( node ) ) { return node ; } node = node . getParent ( ) ; } return null ; }
Returns the deepest shared parent of this node and the specified node . If the nodes are identical then their parent is returned . If one node is the parent of the other then the parent node is returned .