splits the parent node and creates two child nodes (one with the old centre and one with the new one)
17492
void split(treeNode parent, Point newCentre, int newCentreIndex){
		
		//loop counter variable
		int i;

		//1. Counts how many points belong to the new and how many points belong to the old centre
		int nOld = 0;
		int nNew = 0;
		for(i=0;i<parent.n;i++){
			Point centre = determineClosestCentre(parent.points[i], parent.centre, newCentre);
			if(centre == newCentre){
				nNew++;
			} else {
				nOld++;
			} 
		}

		//2. initalizes the arrays for the pointer
		
		//array for pointer on the points belonging to the old centre
		Point[] oldPoints = new Point[nOld];

		//array for pointer on the points belonging to the new centre
		Point[] newPoints = new Point[nNew];

		int indexOld = 0;
		int indexNew = 0;

		for(i=0;i<parent.n;i++){
			Point centre = determineClosestCentre(parent.points[i],parent.centre,newCentre);
			if(centre == newCentre){
				newPoints[indexNew] = parent.points[i];
				newPoints[indexNew].centreIndex = newCentreIndex;
				indexNew++;
			} else if(centre == parent.centre){
				oldPoints[indexOld] = parent.points[i];
				indexOld++;
			} else {
				//printf("ERROR !!! NO CENTER NEAREST !! \n");
			}
		}

		//left child: old centre
		treeNode lc = new treeNode(nOld, oldPoints, 
						parent.centre, parent);
		/*lc.centre = parent.centre;
		lc.points = oldPoints;
		lc.n = nOld;

		lc.lc = null;
		lc.rc = null;
		lc.parent = parent;

		treeNodeTargetFunctionValue(lc);*/
		
		//right child: new centre
		treeNode rc = new treeNode(nNew, newPoints, newCentre, 
							 parent);
		/*rc.centre = newCentre;
		rc.points = newPoints;
		rc.n = nNew;

		rc.lc = null;
		rc.rc = null;
		rc.parent = parent;

		treeNodeTargetFunctionValue(rc);*/

		//set childs of the parent node
		parent.lc = lc;
		parent.rc = rc;

		//propagate the cost changes to the parent nodes
		while(parent != null){
			parent.cost = parent.lc.cost + parent.rc.cost;
			parent = parent.parent;
		}

	}
114132
protected void addChild(Node child, int index, double split) {
        children.add(index, child);
        nodeSplits.put(child, split);
        child.setParent(this);
    }
150950
function (p) {
				if (p) {
					for (var i = 0; i < p.childNodes.length; i++) {
						if (p.childNodes[i].nodeType != 3 && p.childNodes[i].nodeType != 8) {
							var cEl = jsPlumb.getElement(p.childNodes[i]),
								cid = _currentInstance.getId(p.childNodes[i], null, true);
							if (cid && _elementsWithEndpoints[cid] && _elementsWithEndpoints[cid] > 0) {
								var cOff = _currentInstance.getOffset(cEl);
								_delements[id][cid] = {
									id: cid,
									offset: {
										left: cOff.left - parentOffset.left,
										top: cOff.top - parentOffset.top
									}
								};
								_draggablesForElements[cid] = id;
							}
							_oneLevel(p.childNodes[i]);
						}
					}
				}
			}
411380
function (node, newNode) {
        return node.nextSibling ? node.parentNode.insertBefore(newNode, node.nextSibling):
            node.parentNode.appendChild(newNode);
    }
787030
function(item, parentNode) {
			if (!parentNode) {
				if (!this.domNode) {
					this.show();
				}
				parentNode = this.domNode;
			}
			var addCommand = this.itemConstructMap[item.type || 'item'];
			var node = addCommand.call(this, parentNode, item);
			item.domNode = node;
			this.items.push(item);
			return node;
		}
255679
def borrow_from_previous_sibling(prev_node)
      if prev_node.keys.length - 1 > min_keys
        index = @parent.search_node_index(self) - 1

        if is_leaf?
          # Move the last key of the previous node to the front of this node
          @keys.unshift(prev_node.keys.pop)
          # Register the new lead key of this node with its parent
          @parent.keys[index] = @keys.first
          # Move the last value of the previous node to the front of this node
          @values.unshift(prev_node.values.pop)
        else
          # For branch nodes the branch key will be the borrowed key.
          @keys.unshift(@parent.keys[index])
          # And the last key of the previous key will become the new branch
          # key for this node.
          @parent.keys[index] = prev_node.keys.pop
          # Move the last child of the previous node to the front of this node
          @children.unshift(node = prev_node.children.pop)
          node.parent = myself
        end

        return true
      end

      false
    end
289146
def replaceChild(self, new_child: 'WdomElement', old_child: 'WdomElement'
                     ) -> Node:
        """"""
        if self.connected:
            self._replace_child_web(new_child, old_child)
        return self._replace_child(new_child, old_child)
885805
function endNode() {
            if (parent.children) {
                mergeChildren(parent.children);
                sortChildren(parent.children);
            }
            parent = parentsStack.pop();
        }
414341
function (polygons) {
    // new polygons can only be added to root node; children can only be splitted polygons
    if (!this.isRootNode()) {
      throw new Error('Assertion failed')
    }
    let _this = this
    polygons.map(function (polygon) {
      _this.addChild(polygon)
    })
  }
1009335
function(html, current, position) {

      var x, newNode, node, firstChild;

      // create a new node
      newNode = document.createElement('div');
      newNode.innerHTML = html;

      // get new new node
      newNode = newNode.childNodes[0];

      // create new node in mirror
      if (position == 'before') {

        // insert element
        current.parentNode.insertBefore(newNode, current);

      }

      // re-init sortable
      hashedit.setupSortable();

      return newNode;

    }
906915
function (node) {
        var newNode = node.clone();
        var clonedNodesMap = {};
        function buildNodesMap(sNode, tNode) {
            clonedNodesMap[sNode.__uid__] = tNode;

            for (var i = 0; i < sNode._children.length; i++) {
                var sChild = sNode._children[i];
                var tChild = tNode._children[i];
                buildNodesMap(sChild, tChild);
            }
        }
        buildNodesMap(node, newNode);

        newNode.traverse(function (newChild) {
            if (newChild.skeleton) {
                newChild.skeleton = newChild.skeleton.clone(clonedNodesMap);
            }
            if (newChild.material) {
                newChild.material = newChild.material.clone();
            }
        });

        return newNode;
    }
253706
def replaceChild(self, new_child: AbstractNode,
                     old_child: AbstractNode) -> AbstractNode:
        """"""
        return self._replace_child(new_child, old_child)
573032
def split_node
      unless @parent
        # The node is the root node. We need to create a parent node first.
        self.parent = @store.new(BigTreeNode, @tree, false)
        @parent.children[0] = myself
        @tree.root = @parent
      end

      # Create the new sibling that will take the 2nd half of the
      # node content.
      sibling = @store.new(BigTreeNode, @tree, is_leaf?, @parent, myself,
                           @next_sibling)
      # Determine the index of the middle element that gets moved to the
      # parent. The node size must be an uneven number.
      mid = @keys.size / 2
      # Insert the middle element key into the parent node
      @parent.insert_element(@keys[mid], sibling)
      if is_leaf?
        # Copy the keys and values from the mid element onwards into the new
        # sibling node.
        sibling.keys += @keys[mid..-1]
        sibling.values += @values[mid..-1]
        # Delete the copied keys and values from this node.
        @values.slice!(mid..-1)
      else
        # Copy the keys from after the mid value onwards to the new sibling
        # node.
        sibling.keys += @keys[mid + 1..-1]
        # Same for the children.
        sibling.children += @children[mid + 1..-1]
        # Reparent the children to the new sibling parent.
        sibling.children.each { |c| c.parent = sibling }
        # And delete the copied children references.
        @children.slice!(mid + 1..-1)
      end
      # Delete the copied keys from this node.
      @keys.slice!(mid..-1)

      @parent
    end
80965
def distribute(node):
    
    children = list(c for c in node.childNodes if is_element(c))
    unwrap(node)
    tag_name = node.tagName
    for c in children:
        wrap_inner(c, tag_name)
1217456
function(newNode, oldNode) {
        newNode = newNode.get ? newNode.get('element') : newNode;
        oldNode = oldNode.get ? oldNode.get('element') : oldNode;
        return this.get('element').replaceChild(newNode, oldNode);
    }
651701
def after(self, *nodes: Union[AbstractNode, str]) -> None:
        
        if self.parentNode:
            node = _to_node_list(nodes)
            _next_node = self.nextSibling
            if _next_node is None:
                self.parentNode.appendChild(node)
            else:
                self.parentNode.insertBefore(node, _next_node)
1361943
function(node, root) {
    var pn = node.parentNode;
    while (pn) {
      if (pn == root) {
        break;
      }
      pn = pn.parentNode;
    }
    return !!pn;
  }