Add a Tree
 @param [LeafNode] tree_node

 @return self
196940
def add_child(tree_node)
      return if tree_node.parent == self
      if not tree_node.parent.nil?
        tree_node.remove_from_parent
      else
        tree_node.prefix_path = nil
      end
      tree_node.invalidate
      tree_node.parent = self
      if @children.length > 0
        @children.last.next = tree_node
        tree_node.prev      = @children.last
      else
        tree_node.prev = nil
      end
      tree_node.next = nil
      @children << tree_node
      @leaves_and_children << tree_node
      self
    end
869747
public function addChild(self $node)
	{
		$index = count($this->node_children);
		$this->insertChildAt($index, $node);
	}
1250024
def add_child_to_self( self, tree ):
        '''  '''
        assert isinstance(tree, Tree), \
               '(!) Unexpected type of argument for '+argName+'! Should be Tree.'
        if (not self.children):
            self.children = []
        tree.parent = self
        self.children.append(tree)
1306275
def add_root(cls, **kwargs):
        """"""

        # do we have a root node already?
        last_root = cls.get_last_root_node()

        if last_root and last_root.node_order_by:
            # there are root nodes and node_order_by has been set
            # delegate sorted insertion to add_sibling
            return last_root.add_sibling('sorted-sibling', **kwargs)

        if last_root:
            # adding the new root node as the last one
            newtree_id = last_root.tree_id + 1
        else:
            # adding the first root node
            newtree_id = 1

        if len(kwargs) == 1 and 'instance' in kwargs:
            # adding the passed (unsaved) instance to the tree
            newobj = kwargs['instance']
            if newobj.pk:
                raise NodeAlreadySaved("Attempted to add a tree node that is "\
                    "already in the database")
        else:
            # creating the new object
            newobj = get_result_class(cls)(**kwargs)

        newobj.depth = 1
        newobj.tree_id = newtree_id
        newobj.lft = 1
        newobj.rgt = 2
        # saving the instance before returning it
        newobj.save()
        return newobj
1259593
function(elem){
             if(!this.root){
              this.root = struct.Node(elem);
              this.tail = this.root;
              this.size = 1;
              return this;
              // this.root.isRoot = true;
             }
            this.root.prepend(elem);
            this.root = this.root.previous;
            this.size += 1;
            // this.add(elem,this.root);
            return this;
          }
1257437
def insert_tree(self, items, node, headers):
        
        first = items[0]
        child = node.get_child(first)
        if child is not None:
            child.count += 1
        else:
            # Add new child.
            child = node.add_child(first)

            # Link it to header structure.
            if headers[first] is None:
                headers[first] = child
            else:
                current = headers[first]
                while current.link is not None:
                    current = current.link
                current.link = child

        # Call function recursively.
        remaining_items = items[1:]
        if len(remaining_items) > 0:
            self.insert_tree(remaining_items, child, headers)
99099
def _add node, allows_children=true, &block
      #raise ArgumentError, "Argument should be a node" if !node.is_a? TreeNode
      $log.debug " TODO remove from existing parent to avoid bugs XXX"
      if !node.is_a? TreeNode
        n = TreeNode.new node, allows_children, &block
        node = n
      end
      node.parent = self
      @children << node
      node
    end
1164705
def add_child(self, child):
        '''
        '''
        if not isinstance(child, Node):
            raise TypeError("child must be a Node")
        self.children.append(child); child.parent = self
892770
def add_horizontal(node)
      if(node.char > @char)
        if (@right === nil)
          @right = node
        else
          @right.add_horizontal(node)
        end
      else
        if (@left === nil)
          @left = node
        else
          @left.add_horizontal(node)
        end
      end
    end
1062357
def add_node(self, node):
        
        if self.controllers.get(node.controller_type, None):
            raise RuntimeError("Cannot add node {} to the node group. A node for {} group is already assigned".format(
                node,
                node.controller_type
            ))
        self.nodes.append(node)
        if node.controller:
            self.controllers[node.controller_type] = node.controller
            setattr(self, node.controller_type, node.controller)
1334194
function addToTree (elem, callback) {
    const pathElems = toPathComponents(elem.path || '')
    let parent = tree
    const lastIndex = pathElems.length - 1

    let currentPath = ''
    eachOfSeries(pathElems, (pathElem, index, callback) => {
      if (currentPath) {
        currentPath += '/'
      }
      currentPath += pathElem
      const last = (index === lastIndex)
      parent.dirty = true
      parent.multihash = null
      parent.size = null

      if (last) {
        waterfall([
          (callback) => parent.put(pathElem, elem, callback),
          (callback) => flatToShard(null, parent, options.shardSplitThreshold, options, callback),
          (newRoot, callback) => {
            tree = newRoot
            callback()
          }
        ], callback)
      } else {
        parent.get(pathElem, (err, treeNode) => {
          if (err) {
            callback(err)
            return // early
          }
          let dir = treeNode
          if (!dir || !(dir instanceof Dir)) {
            dir = DirFlat({
              dir: true,
              parent: parent,
              parentKey: pathElem,
              path: currentPath,
              dirty: true,
              flat: true
            }, options)
          }
          const parentDir = parent
          parent = dir
          parentDir.put(pathElem, dir, callback)
        })
      }
    }, callback)
  }
635453
private static function addTreeNode(array &$tree, $parent, $node, $prepend = false)
    {
        if ($parent === null) {
            if (array_key_exists($node, $tree)) {
                throw new \Exception('Node already exists');
            }
            if ($prepend) {
                $tree = array_merge([$node => []], $tree);
            } else {
                $tree[$node] = [];
            }

            return true;
        }
        foreach ($tree as $key => &$value) {
            if ($key === $parent) {
                return self::addTreeNode($value, null, $node, $prepend);
            } else {
                if (self::addTreeNode($value, $parent, $node, $prepend)) {
                    return true;
                }
            }
        }

        return false;
    }
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)
86859
def _add_to_tree(tree, word, meaning):
    '''
    
    '''
    if len(word) == 0:
        tree[''] = meaning
    else:
        _add_to_tree(tree[word[0]], word[1:], meaning)
871180
def add(self, *tasks):
        
        nodes = [x.node for x in tasks]
        self.node.add(*nodes)
        return self
925672
def push(node)
      node = Node(node)
      @head ||= node

      if @tail
        @tail.next = node
        node.prev = @tail
      end

      @tail = node

      @length += 1
      self
    end
764074
function addChildren(node) {
    var children = node._private.children;

    for (var i = 0; i < children.length; i++) {
      add(children[i]);
    }
  }