Source:
<code>private void relocateChildrenHashAdders(JsonObject parent){ Set<JsonObject> children = GraphUtilities.getDownstream(parent, graph); if (children.size() == 1) { JsonObject hashAdder = children.iterator().next(); String schema = GraphUtilities.getOutputPortType(hashAdder, 0); JsonObject hashAdderCopy = GraphUtilities.copyOperatorNewName( hashAdder, jstring(hashAdder, "name")); GraphUtilities.removeOperator(hashAdder, graph); GraphUtilities.addBefore(parent, hashAdderCopy, graph); GraphUtilities.setOutputPortType(parent, 0, schema); GraphUtilities.setInputPortType(parent, 0, schema); } else { <START> LinkedList<JsonObject> HashAdders = new LinkedList<>(); <END> LinkedList<JsonObject> others = new LinkedList<>(); children.forEach( (JsonObject parentChild) -> { if (GraphUtilities.isHashAdder(parentChild)) { HashAdders.add(parentChild); } else { others.add(parentChild); } } ); int nUnparallelCopy = 0; for (JsonObject hashAdder: HashAdders) { GraphUtilities.moveOperatorUpstream(hashAdder, graph); JsonObject unparallelCopy = GraphUtilities.copyOperatorNewName( parent, jstring(parent, "name") + "_" + Integer.toString(nUnparallelCopy++)); Set<JsonObject> hashAdderChildren = GraphUtilities.getDownstream(hashAdder, graph); assert hashAdderChildren.size() == 1; JsonObject hashAdderChild = hashAdderChildren.iterator().next(); String schema = GraphUtilities.getOutputPortType(hashAdder, 0); GraphUtilities.setOutputPortType(unparallelCopy, 0, schema); GraphUtilities.setInputPortType(unparallelCopy, 0, schema); GraphUtilities.addBetween(hashAdder, hashAdderChild, unparallelCopy); graph.get("operators").getAsJsonArray().add(unparallelCopy); } if (others.isEmpty()) { GraphUtilities.removeOperator(parent, graph); } } }</code><technical_language>a LinkedList</technical_language>

Target:
private void relocateChildrenHashAdders(JsonObject parent){ Set<JsonObject> children = GraphUtilities.getDownstream(parent, graph); if (children.size() == 1) { JsonObject hashAdder = children.iterator().next(); String schema = GraphUtilities.getOutputPortType(hashAdder, 0); JsonObject hashAdderCopy = GraphUtilities.copyOperatorNewName( hashAdder, jstring(hashAdder, "name")); GraphUtilities.removeOperator(hashAdder, graph); GraphUtilities.addBefore(parent, hashAdderCopy, graph); GraphUtilities.setOutputPortType(parent, 0, schema); GraphUtilities.setInputPortType(parent, 0, schema); } else { ArrayList<JsonObject> hashAdders = new ArrayList<>(); ArrayList<JsonObject> others = new ArrayList<>(); children.forEach( (JsonObject parentChild) -> { if (GraphUtilities.isHashAdder(parentChild)) { hashAdders.add(parentChild); } else { others.add(parentChild); } } ); int nUnparallelCopy = 0; for (JsonObject hashAdder: hashAdders) { GraphUtilities.moveOperatorUpstream(hashAdder, graph); JsonObject unparallelCopy = GraphUtilities.copyOperatorNewName( parent, jstring(parent, "name") + "_" + Integer.toString(nUnparallelCopy++)); Set<JsonObject> hashAdderChildren = GraphUtilities.getDownstream(hashAdder, graph); assert hashAdderChildren.size() == 1; JsonObject hashAdderChild = hashAdderChildren.iterator().next(); String schema = GraphUtilities.getOutputPortType(hashAdder, 0); GraphUtilities.setOutputPortType(unparallelCopy, 0, schema); GraphUtilities.setInputPortType(unparallelCopy, 0, schema); GraphUtilities.addBetween(hashAdder, hashAdderChild, unparallelCopy); graph.get("operators").getAsJsonArray().add(unparallelCopy); } if (others.isEmpty()) { GraphUtilities.removeOperator(parent, graph); } } }