public List getChildsInAllGenerations ( String label ) { if ( label == null || label . equals ( "" ) ) return new ArrayList ( 0 ) ; List ret = new ArrayList ( ) ; Iterator it = childs . iterator ( ) ; while ( it . hasNext ( ) ) { AbcNode abcn = ( AbcNode ) it . next ( ) ; if ( abcn . getLabel ( ) . equals ( label ) ) { ret . add ( abcn ) ; } else { ret . addAll ( abcn . getChildsInAllGenerations ( label ) ) ; } } return ret ; }
Look for child grandchild grand - grand - child having the requested label . When such one is found doesn t continue search into his own childs .