Insert child t at child position i (0..n-1) by shifting children
i+1..n-1 to the right one position. Set parent / indexes properly
but does NOT collapse nil-rooted t's that come in here like addChild.
188907
public void insertChild(int i, Object t) {
		if (i < 0 || i > getChildCount()) {
			throw new IndexOutOfBoundsException(i+" out or range");
		}

		if (children == null) {
			children = createChildrenList();
		}

		children.add(i, t);
		// walk others to increment their child indexes
		// set index, parent of this one too
		this.freshenParentAndChildIndexes(i);
	}
1317582
def insert_position(node)
      case node.type
      when :block
        node.children[1].children.empty? ? node.children[0].loc.expression.end_pos + 3 : node.children[1].loc.expression.end_pos
      when :class
        node.children[1] ? node.children[1].loc.expression.end_pos : node.children[0].loc.expression.end_pos
      else
        node.children.last.loc.expression.end_pos
      end
    end
1195555
def set_child(self, index, child):
        

        if index == 0:
            self.left = child
        else:
            self.right = child
528830
def insert(self, value):
        """"""
        i = 0
        n = len(self._tree)
        while i < n:
            cur = self._tree[i]
            self._counts[i] += 1
            if value < cur:
                i = 2 * i + 1
            elif value > cur:
                i = 2 * i + 2
            else:
                return
        raise ValueError("Value %s not contained in tree." "Also, the counts are now messed up." % value)
1004542
public final boolean addChild(int index, N newChild) {
		if (newChild == null) {
			return false;
		}

		final int count = (this.children == null) ? 0 : this.children.size();

		final N oldParent = newChild.getParentNode();
		if (oldParent != this && oldParent != null) {
			newChild.removeFromParent();
		}

		final int insertionIndex;

		if (this.children == null) {
			this.children = newInternalList(index + 1);
		}

		if (index < count) {
			// set the element
			insertionIndex = Math.max(index, 0);
			this.children.add(insertionIndex, newChild);
		} else {
			// Resize the array
			insertionIndex = this.children.size();
			this.children.add(newChild);
		}

		++this.notNullChildCount;

		newChild.setParentNodeReference(toN(), true);
		firePropertyChildAdded(insertionIndex, newChild);

		return true;
	}
334126
def move_first_element_of_successor_to_child(child_index)
      child = @children[child_index]
      succ = @children[child_index + 1]

      if child.is_leaf?
        # Adjust offset for the successor node
        @offsets[child_index + 1] += 1
        # Move the value
        child.values << succ.values.shift
      else
        # Before:
        #
        # Root Node             +--------------------------------+
        # Offsets               | 0                            7 |
        # Children                |                            |
        #              child      v    succ                    v
        # Level 1    +---------------++-------------------------------------+
        # Offsets    | 0         4   ||    0         4          6         9 |
        # Children     |         |         |         |          |         |
        #              v         v         v         v          v         v
        # Leaves  +---------++-------++----------++-------++----------++-------+
        # Values  | A B C D || E F G || H I J K  || L  M  || N  O  P  || Q  R  |
        #
        # Index     0 1 2 3    4 5 6    7 8 9 10    11 12    13 14 15    16 17
        #
        # After:
        #
        # Root Node             +--------------------------------+
        # Offsets               | 0                           11 |
        # Children                |                            |
        #              child      v                succ        v
        # Level 1    +--------------------------++--------------------------+
        # Offsets    | 0         4         7    ||   0          2         5 |
        # Children     |         |         |         |          |         |
        #              v         v         v         v          v         v
        # Leaves  +---------++-------++----------++-------++----------++-------+
        # Values  | A B C D || E F G || H I J K  || L  M  || N  O  P  || Q  R  |
        #
        # Index     0 1 2 3    4 5 6    7 8 9 10    11 12    13 14 15    16 17
        #
        # Adjust the offsets of the successor. The 2nd original offset
        # determines the delta for the parent node.
        succ.offsets.shift
        delta = succ.offsets.first
        succ.offsets.map! { |o| o -= delta }
        # The additional child offset can be taken from the parent node
        # reference.
        child.offsets << @offsets[child_index + 1]
        # The parent node offset of the successor needs to be corrected by the
        # delta value.
        @offsets[child_index + 1] += delta
        # Move the child reference
        child.children << succ.children.shift
        child.children.last.parent = child
      end
    end
458451
private int insertNodeBetween(int index, int nextIndex, long node) {
        assert(previousIndexFromNode(node) == 0);
        assert(nextIndexFromNode(node) == 0);
        assert(nextIndexFromNode(nodes.elementAti(index)) == nextIndex);
        // Append the new node and link it to the existing nodes.
        int newIndex = nodes.size();
        node |= nodeFromPreviousIndex(index) | nodeFromNextIndex(nextIndex);
        nodes.addElement(node);
        // nodes[index].nextIndex = newIndex
        node = nodes.elementAti(index);
        nodes.setElementAt(changeNodeNextIndex(node, newIndex), index);
        // nodes[nextIndex].previousIndex = newIndex
        if(nextIndex != 0) {
            node = nodes.elementAti(nextIndex);
            nodes.setElementAt(changeNodePreviousIndex(node, newIndex), nextIndex);
        }
        return newIndex;
    }
688673
def add_child(self, child):
        
        self.children.append(child)
        child.parent = self
        self.udepth = max([child.udepth for child in self.children]) + 1
1298529
def add_child(self, tree):
        '''
        '''
        tree.parent = self
        self.children.append(tree)
        return tree
1102786
def add_child(self, u, v):
        ''' 
        '''

        if u == -1:
            self.root = v
            self.adj_list[v] = []
            return
        if v not in self.adj_list[u]:
            self.adj_list[u].append(v)
        if v not in self.adj_list:
            self.adj_list[v] = []
291448
def add_child(self, item):
        """"""
        item.depth = self.depth + 1
        self.childs.append(item)
        self.childs = sorted(self.childs, key=lambda item: item.order if item.order else 999)
134694
public void insertChild(CmsTreeItem item, int position) {

        m_children.insert(item, position);
        adopt(item);
    }
1323444
def insert_child(self, i, child):
        
        child.parent = self
        self.children.insert(i, child)
        self.changed()
323287
def insert(self, value):
        
        side = '_lesser' if value < self.value else '_greater'
        child = getattr(self, side)
        if child is None:
            setattr(self, side, _BinarySearchTree(value))
        else:
            child.insert(value)
1140141
function insert (parent, children) {
  if (!parent || !children) {
    return
  }
  let nodes = Array.prototype.slice.call(children)
  if (nodes.length === 0) {
    nodes.push(children)
  }
  for (let i = 0; i < nodes.length; i++) {
    if (this.contains(nodes[i], parent)) {
      continue
    }
    if (nodes[i] !== parent && parent.appendChild) {
      parent.appendChild(nodes[i])
    }
  }
}
963107
Node insertChildAt(Node newChild, int index) throws DOMException {
        if (newChild instanceof DocumentFragment) {
            NodeList toAdd = newChild.getChildNodes();
            for (int i = 0; i < toAdd.getLength(); i++) {
                insertChildAt(toAdd.item(i), index + i);
            }
            return newChild;
        }

        LeafNodeImpl toInsert = (LeafNodeImpl) newChild;
        if (toInsert.document != null && document != null && toInsert.document != document) {
            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, null);
        }
        if (toInsert.isParentOf(this)) {
            throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, null);
        }

        if (toInsert.parent != null) {
            int oldIndex = toInsert.index;
            toInsert.parent.children.remove(oldIndex);
            toInsert.parent.refreshIndices(oldIndex);
        }

        children.add(index, toInsert);
        toInsert.parent = this;
        refreshIndices(index);

        return newChild;
    }
236107
def insert_or_append(parent, node, next_sibling):
    
    # simple insert
    if next_sibling:
        parent.insertBefore(node, next_sibling)
    else:
        parent.appendChild(node)