public void takeChildren ( Vector < BoxNode > list ) { for ( Iterator < BoxNode > it = list . iterator ( ) ; it . hasNext ( ) ; ) { BoxNode node = it . next ( ) ; if ( node . nearestParent . equals ( this ) ) { appendChild ( node ) ; it . remove ( ) ; } } //let the children take their children for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) ( ( BoxNode ) getChildAt ( i ) ) . takeChildren ( list ) ; }
Goes through the parent s children takes all the nodes that are inside of this node and makes them the children of this node . Then recursively calls the children to take their nodes .