void ( RefClass refClass, Set<? super RefClass> newDependents) { final LinkedList<RefClass> pendingClasses = new LinkedList<>(); final Set<RefClass> processedClasses = new HashSet<>(); pendingClasses.addLast(refClass); while (!pendingClasses.isEmpty()) { final RefClass classToProcess = pendingClasses.removeFirst(); newDependents.add(classToProcess); processedClasses.add(classToProcess); final Set<RefClass> dependents = calculateInitializationDependentsForClass(classToProcess); for (RefClass dependent : dependents) { if (!pendingClasses.contains(dependent) && !processedClasses.contains(dependent)) { pendingClasses.addLast(dependent); } } } newDependents.remove(refClass); }