where we work only on the newest child node, which may construct many spill-over parents as it goes
502661
NodeBuilder ascendToRoot()
    {
        NodeBuilder current = this;
        while (!current.isRoot())
            current = current.ascend();
        return current;
    }
683510
function(newNode, refNode){
      var nodes = this.nodes;
      var pos = refNode ? nodes.indexOf(refNode) : -1;

      if (pos == -1)
      {
        nodes.push(newNode);
        this.last = newNode;
      }
      else
        nodes.splice(pos, 0, newNode);

      this.first = nodes[0];

      newNode.groupNode = this;

      this.emit_childNodesModified({ inserted: [newNode] });
    }
513578
public final void addChildBefore(Node newChild, Node node) {
    checkArgument(node.parent == this, "The existing child node of the parent should not be null.");
    checkArgument(newChild.next == null, "The new child node has next siblings.");
    checkArgument(newChild.previous == null, "The new child node has previous siblings.");
    checkArgument(newChild.parent == null, "The new child node already has a parent.");
    if (first == node) {
      Node last = first.previous;
      // NOTE: last.next remains null
      newChild.parent = this;
      newChild.next = first;
      newChild.previous = last;
      first.previous = newChild;
      first = newChild;
    } else {
      addChildAfter(newChild, node.previous);
    }
  }
971160
public void checkParentLinks() {
        this.visit(new NodeVisitor() {
            @Override
            public boolean visit(AstNode node) {
                int type = node.getType();
                if (type == Token.SCRIPT)
                    return true;
                if (node.getParent() == null)
                    throw new IllegalStateException
                            ("No parent for node: " + node
                             + "\n" + node.toSource(0));
                return true;
            }
        });
    }
537682
function() {
            if (!this.removed) {
                this.removed = true;

                if (_CSGDEBUG) {
                    if (this.isRootNode()) throw new Error("Assertion failed"); // can't remove root node
                    if (this.children.length) throw new Error("Assertion failed"); // we shouldn't remove nodes with children
                }

                // remove ourselves from the parent's children list:
                var parentschildren = this.parent.children;
                var i = parentschildren.indexOf(this);
                if (i < 0) throw new Error("Assertion failed");
                parentschildren.splice(i, 1);

                // invalidate the parent's polygon, and of all parents above it:
                this.parent.recursivelyInvalidatePolygon();
            }
        }
961058
private Node<K, V> cutOldestChild(Node<K, V> n) {
        Node<K, V> oldestChild = n.o_c;
        if (oldestChild != null) {
            if (oldestChild.y_s != null) {
                oldestChild.y_s.o_s = n;
            }
            n.o_c = oldestChild.y_s;
            oldestChild.y_s = null;
            oldestChild.o_s = null;
        }
        return oldestChild;
    }
254582
def add_node(node, parent):
    '''
    '''
    newNode = dict(node_id=node.id, children=[])
    parent["children"].append(newNode)
    if node.left: add_node(node.left, newNode)
    if node.right: add_node(node.right, newNode)
827774
public static boolean parentContainsOnlyLeaves(ParentNode parentNode) {
        for (Node child : parentNode.children()) {
            if (!isLeaf(child)) return false;
        }
        return true;
    }
873105
function _onSetChildNodes(event, res) {
        // res = {parentId, nodes}
        var node = nodeWithId(res.parentId);
        node.setChildrenPayload(res.nodes);
        if (_pendingRequests > 0 && --_pendingRequests === 0) {
            _onFinishedLoadingDOM();
        }
    }
1140826
function(nodeModel, excludes) {
			if(nodeModel){
				this._expandRecursively(nodeModel, excludes);
			} else {
				if(!this._navHandler){
					return;
				}
				//We already know what the top level children is under the root, from the navigation handler.
				var topLevelNodes = this._navHandler.getTopLevelNodes();
				for (var i = 0; i < topLevelNodes.length ; i++){
					this._expandRecursively(topLevelNodes[i], excludes);
				}
			}
		}
945860
function (node) {
        var originalParent = node._parent;
        if (originalParent === this) {
            return;
        }
        if (originalParent) {
            originalParent.remove(node);
        }
        node._parent = this;
        this._children.push(node);

        var scene = this._scene;
        if (scene && scene !== node.scene) {
            node.traverse(this._addSelfToScene, this);
        }
        // Mark children needs update transform
        // In case child are remove and added again after parent moved
        node._needsUpdateWorldTransform = true;
    }
971838
def extend_parents(parents):
    
    new_parents = set()

    for parent in parents:

        new_parents.add(parent)

        if isinstance(parent, DeterministicBase):
            new_parents.remove(parent)
            new_parents |= parent.extended_parents

        elif isinstance(parent, ContainerBase):
            for contained_parent in parent.stochastics:
                new_parents.add(contained_parent)
            for contained_parent in parent.deterministics:
                new_parents |= contained_parent.extended_parents

    return new_parents
821193
function(newnode, oldnode, ids) {
		var updates = [];
		var news = this._assistant.index(newnode.childNodes);
		var olds = this._assistant.index(oldnode.childNodes);
		/*
		 * Add elements?
		 */
		var child = newnode.lastElementChild,
			topid = this._assistant.id(oldnode),
			oldid = null,
			newid = null;
		while (child) {
			newid = this._assistant.id(child);
			if (!olds[newid]) {
				if (oldid) {
					updates.push(
						new edbml.InsertUpdate(this._doc).setup(oldid, child)
					);
				} else {
					updates.push(
						new edbml.AppendUpdate(this._doc).setup(topid, child)
					);
				}
			} else {
				oldid = newid;
			}
			child = child.previousElementSibling;
		}
		/*
		 * Remove elements?
		 */
		Object.keys(olds).forEach(function(id) {
			if (!news[id]) {
				updates.push(
					new edbml.RemoveUpdate(this._doc).setup(id)
				);
				updates.push(
					new edbml.FunctionUpdate(this._doc).setup(id)
				);
			} else { // note that crawling continues here...
				var n1 = news[id];
				var n2 = olds[id];
				this._scan(n1, n2, n1, id, ids);
			}
		}, this);
		/*
		 * Register updates
		 */
		updates.reverse().forEach(function(update) {
			this._updates.collect(update, ids);
		}, this);
	}
4801
protected void visitChildren(ParentNode<? extends N> node) {
    List<? extends N> children = node.getChildren();
    int size = children.size();
    for (int i = 0; i < size; i++) {
      visit(children.get(i));
    }
  }
1075415
function setParents () {
		var q = async.queue(processFile, 1)
		q.drain = function () { self.emit('drain') }

		// Process files with no dependency first
		self.nodeps.forEach( q.push )

		function processFile (item, cb) {
			debug('dep:', item.id)
			// Add files with no dependency left to be processed
			self.deps
				.forEach(function (file) {
					if ( file.count > 0 && file.deps.indexOf(item.id) >= 0 ) {
						item.parents.push(file.id)
						file.count--
						debug('file %s -> %d', file.id, file.count)
						if (file.count === 0) q.push(file)
					}
				})
			cb()
		}
	}
857486
def fixup_parents(self, node, parent):
        """"""
        start, finish = 0, self.last_finish
        # We assume anything with a start has a finish.
        needs_range = not hasattr(node, 'start')

        if not hasattr(node, 'parent'):
            node.parent = parent

        for n in node:
            if needs_range and hasattr(n, 'start'):
                if n.start < start: start = n.start
                if n.finish > finish: finish = n.finish

            if hasattr(n, 'offset') and not hasattr(n, 'parent'):
                n.parent = node
            else:
                self.fixup_parents(n, node)
                pass
            pass
        if needs_range:
            node.start, node.finish = start, finish

        return
1171765
public synchronized boolean changeParent(int depStreamID, int newPriority, int newParentStreamID, boolean exclusive) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "changeParent entry: depStreamID: " + depStreamID + " newParentStreamID: " + newParentStreamID + " exclusive: " + exclusive);
        }

        // notice that the new dependent node and parent do not have to be directly related coming into this method.
        // Therefore, find both nodes starting at the root.
        Node depNode = root.findNode(depStreamID);
        Node newParentNode = root.findNode(newParentStreamID);
        if ((depNode == null) || (newParentNode == null)) {
            return false;
        }

        // If the new parent can not be found in the tree under the dependent node, then changing parents is straight forward.
        if (depNode.findNode(newParentStreamID) == null) {
            // simple move, since the new parent is not a dependent of the stream that is changing parents
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "new parent is not a dependent of the stream that is changing parents");
            }
            Node oldParent = depNode.getParent();

            // move the dependent node, reset write counters, and re-sort the affected set of siblings according to original priorities
            depNode.setParent(newParentNode, true);
            depNode.setPriority(newPriority);

            newParentNode.clearDependentsWriteCount();
            newParentNode.sortDependents();

            // where it left from needs to be re-sorted also
            oldParent.clearDependentsWriteCount();
            oldParent.sortDependents();

            // according to spec: after setting the new parent, if this node is to be exclusive, then invode the exclusive algorithm on it.
            if (exclusive) {
                makeExclusiveDependency(depNode, newParentNode);
            }

        } else {
            // so much for simple.  The parent is in the dependency tree underneath the node that we now want to be dependent on the new Parent.
            // in the above example: A - depNode,  D - newParentNode.
            // The below steps are following how that spec says to handle this case (or at least it is suppose to).
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "new parent is a dependent of the stream that is changing parents");
            }

            // move the current newParentNode to be the dependent on the new dependent node's previous parent.
            Node grandParent = depNode.getParent();
            Node oldDepParent = newParentNode.getParent();
            newParentNode.setParent(grandParent, true); // set Parent will also remove newParentNode as a dependent of its current/old parent

            // now make the new dependent node depend on the newParentNode
            depNode.setParent(newParentNode, true);
            depNode.setPriority(newPriority);

            // clear and re-sort the effective levels we touched
            grandParent.clearDependentsWriteCount();
            grandParent.sortDependents();

            newParentNode.clearDependentsWriteCount();
            newParentNode.sortDependents();

            oldDepParent.clearDependentsWriteCount();
            oldDepParent.sortDependents();

            // and finally if the new dependency node is suppose to end up exclusive, make it so now.
            if (exclusive) {
                makeExclusiveDependency(depNode, newParentNode);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "changeParent exit: depNode on exit: " + depNode.toStringDetails());
        }

        return true;

    }