we elevate every node to an entity and set parent pointers
960349
protected function convertNodes(Array $nodes, $em) {
    // our test project (this) is defined to have only de as i18n but dont get confused, these are english wordings
    $navigationNodes = array();

    foreach ($nodes as $node) {
      $node = (object) $node;
      $navigationNode = $this->createNode(array('de'=>$node->title));
      $navigationNode->setContext($this->context);
      $navigationNode->generateSlugs();

      $page = $this->createPage($navigationNode->getSlug('de'));
      $page->setActive(TRUE);
      $em->persist($page);

      $navigationNode->setPage($page);

      $navigationNodes[$navigationNode->getTitle('de')] = $navigationNode;
    }

    foreach ($nodes as $node) {
      $node = (object) $node;

      if (isset($node->parent)) {
        $navigationNodes[$node->title]->setParent($navigationNodes[$node->parent]);
      }
    }

    return $navigationNodes;
  }
1037416
function parents() {
                var parent = void 0,
                    path = [];

                while (!!(parent = el.parentNode)) {
                    path.push(parent);
                    el = parent;
                }

                return path;
            }
930538
private static void PTC1(Program program, TreeNode parent_node, double p, int allowableDepth, RandEngine randEngine)
   {
      int child_count = parent_node.arity();

      for (int i = 0; i != child_count; i++)
      {
         Primitive data;
         if (allowableDepth == 0)
         {
            data = program.anyTerminal(randEngine);
         }
         else if (randEngine.uniform() <= p)
         {
            data = program.anyOperator(randEngine);
         }
         else
         {
            data = program.anyTerminal(randEngine);
         }

         TreeNode child = new TreeNode(data);
         parent_node.getChildren().add(child);

         if(!data.isTerminal())
         {
            PTC1(program, child, p, allowableDepth - 1, randEngine);
         }
      }
   }
469649
private void traverseStoredDescendants(ItemData parent, DataManager dataManager, int action,
      Map<String, ItemData> ret, boolean listOnly, Collection<ItemState> transientDescendants)
      throws RepositoryException
   {

      if (parent.isNode() && !isNew(parent.getIdentifier()))
      {
         if (action != MERGE_PROPS)
         {
            List<NodeData> childNodes = dataManager.getChildNodesData((NodeData)parent);
            for (int i = 0, length = childNodes.size(); i < length; i++)
            {
               NodeData childNode = childNodes.get(i);
               ret.put(childNode.getIdentifier(), childNode);
            }
         }
         if (action != MERGE_NODES)
         {
            List<PropertyData> childProps =
               listOnly ? dataManager.listChildPropertiesData((NodeData)parent) : dataManager
                  .getChildPropertiesData((NodeData)parent);
            outer : for (int i = 0, length = childProps.size(); i < length; i++)
            {
               PropertyData childProp = childProps.get(i);
               for (ItemState transientState : transientDescendants)
               {
                  if (!transientState.isNode() && !transientState.isDeleted()
                     && transientState.getData().getQPath().getDepth() == childProp.getQPath().getDepth()
                     && transientState.getData().getQPath().getName().equals(childProp.getQPath().getName()))
                  {
                     continue outer;
                  }
               }
               if (!childProp.getQPath().isDescendantOf(parent.getQPath(), true))
               {
                  // In case we get the data from the cache, we need to set the correct path
                  QPath qpath = QPath.makeChildPath(parent.getQPath(), childProp.getQPath().getName());
                  childProp =
                     new PersistedPropertyData(childProp.getIdentifier(), qpath, childProp.getParentIdentifier(),
                        childProp.getPersistedVersion(), childProp.getType(), childProp.isMultiValued(),
                        childProp.getValues(), new SimplePersistedSize(
                           ((PersistedPropertyData)childProp).getPersistedSize()));
               }
               ret.put(childProp.getIdentifier(), childProp);
            }
         }
      }
   }
942106
function parentise(tree, h)
{
	if (h === tree.height)
	{
		return tree;
	}

	return {
		ctor: '_Array',
		height: h,
		table: [parentise(tree, h - 1)],
		lengths: [length(tree)]
	};
}
802121
function concatenate(node, index, parent) {
        if (
            parent &&
            (parent.type === 'ParagraphNode' || parent.type === 'RootNode') &&
            queue.indexOf(parent) === -1
        ) {
            queue.push(parent);
        }
    }
615777
function ancestor(node, visitors, base, state) {
  if (!base) base = exports.base;
  if (!state) state = [];(function c(node, st, override) {
    var type = override || node.type,
        found = visitors[type];
    if (node != st[st.length - 1]) {
      st = st.slice();
      st.push(node);
    }
    base[type](node, st, c);
    if (found) found(node, st);
  })(node, state);
}
295393
function initNodeCpt(values, parents, probs) {
    var cpt = initCptWithParents(values, parents, 0);
    setNodeCptProbs(cpt, probs, 0);
    return cpt;
  }
1262252
function Node(key, value) {
  this.key = key;
  this.value = value;
  this.degree = 0;
  this.parent = undefined;
  this.child = undefined;
  this.sibling = undefined;
}
398573
private static void traverseAndBuild(int height, int pos, List<Sha256Hash> allLeafHashes, byte[] includeBits,
                                         List<Boolean> matchedChildBits, List<Sha256Hash> resultHashes) {
        boolean parentOfMatch = false;
        // Is this node a parent of at least one matched hash?
        for (int p = pos << height; p < (pos+1) << height && p < allLeafHashes.size(); p++) {
            if (Utils.checkBitLE(includeBits, p)) {
                parentOfMatch = true;
                break;
            }
        }
        // Store as a flag bit.
        matchedChildBits.add(parentOfMatch);
        if (height == 0 || !parentOfMatch) {
            // If at height 0, or nothing interesting below, store hash and stop.
            resultHashes.add(calcHash(height, pos, allLeafHashes));
        } else {
            // Otherwise descend into the subtrees.
            int h = height - 1;
            int p = pos * 2;
            traverseAndBuild(h, p, allLeafHashes, includeBits, matchedChildBits, resultHashes);
            if (p + 1 < getTreeWidth(allLeafHashes.size(), h))
                traverseAndBuild(h, p + 1, allLeafHashes, includeBits, matchedChildBits, resultHashes);
        }
    }
1188164
function() {
			var parent = this.parent;
			var ix = parent.children.indexOf(this);
			var items = utils.flatten(arguments);
			spliceFn.apply(parent.children, [ix, 1].concat(items));
			
			// update parent
			items.forEach(function(item) {
				item.parent = parent;
			});
		}
17874
function flattenNodeGenerator(node, parent, index, settings, stack) {
  const { itemsKey, idKey } = settings;

  return function flattenNode(list) {
    node = settings.initNode(node);
    node[idKey] = node[idKey] || settings.generateUniqueId();
    list.push(node);

    if (node[itemsKey]) {
      for (let i = 0, len = node[itemsKey].length; i < len; i++) {
        stack.push(
          flattenNodeGenerator(
            node[itemsKey][i],
            node,
            i,
            settings,
            stack
          )
        );
      }
    }

    if (parent && parent[itemsKey]) {
      // Records children' id
      parent[itemsKey][index] = node[idKey];
      node.parent = parent[idKey];
    }

    return list;
  };
}
260247
function (context) {
            var parent = context.stack.top();
            parent && parent.addChild(this);
            context.stack.push(this);
        }
1058929
private void fillNodeList(P parent) {
		P prt = parent;
		if ((prt != null) && (prt.isLeaf())) {
			return;
		}
		while (prt != null) {
			if (!prt.isLeaf()) {
				if (!this.expandedNodes.contains(prt)) {
					this.expandedNodes.add(prt);
					for (int i = prt.getChildCount() - 1; i >= 0; --i) {
						final C child = prt.getChildAt(i);
						if (child != null) {
							final P cn = toTraversableChild(prt, child);
							if (cn != null) {
								this.availableNodes.push(cn);
							}
						}
					}
				} else {
					return;
				}
			}
			prt = this.availableNodes.isEmpty() ? null : this.availableNodes.peek();
			if ((prt != null) && (prt.isLeaf())) {
				return;
			}
		}
	}
466700
function (src, destId, next, parent) {
            var oldId = src.id;
            src.parent = destId;

            async.waterfall([
                async.apply(_getAncestorsFromImmediateParent, destId, parent),
                function saveNodesAncestors(newAncestors, next) {
                    src.ancestors = newAncestors;
                    src._id = new ObjectId();
                    pendingInsertNodes.push(src);
                    async.parallel([
                            function findContentEntries(next) {
                                contentModel.find({"meta.node": oldId}).exec(function (err, data) {
                                    if (err) {
                                        next(err);
                                    }
                                    else {
                                        next(null, data);
                                    }
                                });
                            },
                            function findNodeEntries(next) {
                                nodeModel.find({parent: oldId}).exec(function (err, data) {
                                    if (err) {
                                        next(err);
                                    }
                                    else {
                                        next(null, data);
                                    }
                                });
                            }
                        ],
                        function handleFoundContentAndNodes(err, data) {
                            var contentEntries = data[0], nodeEntries = data[1];
                            _.each(contentEntries, function (item) {
                                item.meta.node = src._id;
                                item._id = new ObjectId();
                                pendingInsertContent.push(item);
                            });
                            if (!nodeEntries.length) {
                                next();
                            }
                            else {
                                async.each(nodeEntries, function (item, next) {
                                    _recursiveCopyNodes(item, src._id, next, src);
                                }, function (err) {
                                    next(err);
                                });
                            }
                        });

                }
            ], function (err) {
                next(err);
            });
        }
1112205
function( nodeStructure, id, parentId, tree, stackParentId ) {
        this.reset( nodeStructure, id, parentId, tree, stackParentId );
    }
944763
function(node) { 
        var p = node.parent;

        // Update the parent's collection of children
        var a = [];

        for (var i=0, len=p.children.length;i<len;++i) {
            if (p.children[i] != node) {
                a[a.length] = p.children[i];
            }
        }

        p.children = a;

        // reset the childrenRendered flag for the parent
        p.childrenRendered = false;

         // Update the sibling relationship
        if (node.previousSibling) {
            node.previousSibling.nextSibling = node.nextSibling;
        }

        if (node.nextSibling) {
            node.nextSibling.previousSibling = node.previousSibling;
        }

		if (this.currentFocus == node) {
			this.currentFocus = null;
		}
		if (this._currentlyHighlighted == node) {
			this._currentlyHighlighted = null;
		}

        node.parent = null;
        node.previousSibling = null;
        node.nextSibling = null;
        node.tree = null;

        // Update the tree's node collection 
        delete this._nodes[node.index];
    }