public Set < String > getIdsForIdWithDescendants ( String s ) { buildIsTypeOf ( ) ; Stack < String > idsToConsider = new Stack < String > ( ) ; idsToConsider . add ( s ) ; Set < String > resultIds = new HashSet < String > ( ) ; while ( ! idsToConsider . isEmpty ( ) ) { String id = idsToConsider . pop ( ) ; if ( ! resultIds . contains ( id ) ) { resultIds . add ( id ) ; if ( terms . containsKey ( id ) ) idsToConsider . addAll ( terms . get ( id ) . getIsTypeOf ( ) ) ; } } return resultIds ; }
Given a set of IDs return a set that contains all of the IDs the children of those IDs the grandchildren etc .