private static Tree traverse ( Tree parent , List < Tree > kids , Tree node ) { for ( Tree kid : kids ) { if ( kid == node ) { return parent ; } Tree ret = node . parent ( kid ) ; if ( ret != null ) { return ret ; } } return null ; }
traverses the tree by recursion