public SpecTopic getClosestTopic ( final SpecTopic topic , final boolean checkParentNode ) { /* * Check this topic to see if it is the topic we are looking for */ if ( this == topic || getId ( ) . equals ( topic . getId ( ) ) ) return this ; /* * If we still haven't found the closest node then check this nodes parents. */ if ( getParent ( ) != null ) { if ( getParent ( ) instanceof Level ) { return ( ( Level ) getParent ( ) ) . getClosestTopic ( topic , checkParentNode ) ; } else if ( getParent ( ) instanceof KeyValueNode ) { return ( ( KeyValueNode ) getParent ( ) ) . getParent ( ) . getBaseLevel ( ) . getClosestTopic ( topic , checkParentNode ) ; } } return null ; }
Finds the closest node in the contents of a level