private static Set<Node> removeExternallyUsedNodes(Set<Node> set){
  boolean change;
  do {
    change=false;
    for (Iterator<Node> iter=set.iterator(); iter.hasNext(); ) {
      Node node=iter.next();
      for (      Node usage : node.usages()) {
        if (!set.contains(usage)) {
          change=true;
          iter.remove();
          break;
        }
      }
    }
  }
 while (change);
  return set;
}

private static Set < Node > removeExternallyUsedNodes ( Set < Node > set ) { boolean change ; do { change = false ; for ( Iterator < Node > iter = set . iterator ( ) ; iter . hasNext ( ) ; ) { Node node = iter . next ( ) ; for ( Node usage : node . usages ( ) ) { if ( ! set . contains ( usage ) ) { change = true ; iter . remove ( ) ; break ; } } } } while ( change ) ; return set ; }
removes nodes from a given set that ( transitively ) have a usage outside the set .
