private static void replaceInTerminalMolecules(Set<TerminalMolecule> terminalMolecules, Set<? extends Node> replacingNodes, FunctionallyGroundedNode newNode) {
Set<TerminalMolecule> newTerminalMolecules = new HashSet<TerminalMolecule>();
for (Iterator<TerminalMolecule> iter = terminalMolecules.iterator(); iter.hasNext();) {
TerminalMolecule current = iter.next();
try {
SimpleTerminalMolecule newMolecule = new SimpleTerminalMolecule();
newMolecule.addAll(GraphUtil.replaceNode(current, replacingNodes, newNode));
newMolecule.markFinalized();
iter.remove();
newTerminalMolecules.add(newMolecule);
} catch (SourceNodeNotFoundException e) {
//nothing, did not remove
}