for(Set<Proposition> goalProps : pn.getGoalPropositions().values())
toAdd.addAll(goalProps);
for(Set<Proposition> legalProps : pn.getLegalPropositions().values())
toAdd.addAll(legalProps);
while(!toAdd.isEmpty()) {
Component curComp = toAdd.pop();
if(usefulComponents.contains(curComp))
//We've already added it
continue;
usefulComponents.add(curComp);
toAdd.addAll(curComp.getInputs());
}
//Remove the components not marked as useful
List<Component> allComponents = new ArrayList<Component>(pn.getComponents());
for(Component c : allComponents) {