void prune ( int depth ) { if ( isImmutable ) throw new IllegalStateException ( "PolicyNode is immutable" ) ; // if we have no children, we can't prune below us... if ( mChildren . size ( ) == 0 ) return ; Iterator < PolicyNodeImpl > it = mChildren . iterator ( ) ; while ( it . hasNext ( ) ) { PolicyNodeImpl node = it . next ( ) ; node . prune ( depth ) ; // now that we've called prune on the child, see if we should // remove it from the tree if ( ( node . mChildren . size ( ) == 0 ) && ( depth > mDepth + 1 ) ) it . remove ( ) ; } }
Removes all paths which don t reach the specified depth .