Node insert(Node parent, Node child) { Node newChild = addNode(parent, child); for (Edge edge : graph.outgoingEdgesOf(parent)) { Node oldChild = edge.getTarget(); graph.removeEdge(parent, oldChild); oldChild.removeParentStreams(parent); addNode(newChild, oldChild); } return newChild; }