Adding or deleting children if needed
167541
protected function manageRelations()
    {
        foreach ($this->_children as $p => $kids) {
            $parent = $this->_items[$p];

            foreach ($kids as $k) {
                $kid = $this->_items[$k];

                if (!$this->_auth->hasChild($parent, $kid)) {
                    Console::stdout($kid->name . ' added as a child of ' . $parent->name . "\n");
                    $this->_auth->addChild($parent, $kid);
                }
            }

            foreach ($this->_auth->getChildren($p) as $current_kid) {
                if (!in_array($current_kid->name, $kids)) {
                    Console::stdout(Console::ansiFormat('Relation between  ' . $current_kid->name . ' and ' . $parent->name . " was removed!\n", [Console::FG_RED]));
                    $this->_auth->removeChild($parent, $current_kid);
                }
            }
        }
    }
1327149
def child_added(self, child):
        
        super(UiKitView, self).child_added(child)

        layout = self.layout
        for i, child_widget in enumerate(self.child_widgets()):
            if child_widget == child.widget:
                layout.insertArrangedSubview(child_widget, atIndex=i)
                layout.insertSubview(child_widget, atIndex=i)
396863
public void addChildren( AstNode first,
                             AstNode second,
                             AstNode third ) {
        if (first != null) {
            this.addLastChild(first);
        }
        if (second != null) {
            this.addLastChild(second);
        }
        if (third != null) {
            this.addLastChild(third);
        }
    }
292933
def add_missing_children(required_children, element_children):
    
    element_tags = [element.tag for element in element_children]
    # Loop through the elements that should be in the form.
    for contained_element in required_children:
        # If the element doesn't exist in the form,
        # add the element to the children.
        if contained_element not in element_tags:
            try:
                added_child = PYUNTL_DISPATCH[contained_element](content='')
            except:
                added_child = PYUNTL_DISPATCH[contained_element]()
            element_children.append(added_child)
    return element_children
765033
function() {
      this.sheets = this.findNodes(SHEET_SELECTOR);
      this.sheets.forEach(function(s) {
        if (s.parentNode) {
          s.parentNode.removeChild(s);
        }
      });
    }
1237481
protected void removeInvalidChildren() {

        if (getLoadState() == LoadState.LOADED) {
            List<CmsSitemapTreeItem> toDelete = new ArrayList<CmsSitemapTreeItem>();
            for (int i = 0; i < getChildCount(); i++) {
                CmsSitemapTreeItem item = (CmsSitemapTreeItem)getChild(i);
                CmsUUID id = item.getEntryId();
                if ((id != null) && (CmsSitemapView.getInstance().getController().getEntryById(id) == null)) {
                    toDelete.add(item);
                }
            }
            for (CmsSitemapTreeItem deleteItem : toDelete) {
                m_children.removeItem(deleteItem);
            }
        }
    }
913637
function _addNewEntries(treeData, added) {
        added.forEach(function (filePath) {
            var isFolder = _.last(filePath) === "/";

            filePath = isFolder ? filePath.substr(0, filePath.length - 1) : filePath;

            var parentPath = FileUtils.getDirectoryPath(filePath),
                parentObjectPath = _filePathToObjectPath(treeData, parentPath),
                basename = FileUtils.getBaseName(filePath);

            if (parentObjectPath) {
                // Verify that the children are loaded
                var childrenPath = _.clone(parentObjectPath);
                childrenPath.push("children");
                if (treeData.getIn(childrenPath) === null) {
                    return;
                }

                treeData = _createPlaceholder(treeData, parentPath, basename, isFolder, {
                    notInCreateMode: true,
                    doNotOpen: true
                });
            }
        });

        return treeData;
    }
455215
function(element, child){
    if(_.isString(child))
      element.innerHTML += child;
    else if (_.isElement(child))
      element.appendChild(child);
  }
114986
function () {
		var c$ = this.$.menu.children;
		var c = c$[0];
		if (c) {
			//remove any applied movedClass
			if (this.movedClass && this.movedClass.length > 0 && c.hasClass(this.movedClass)) {
				c.removeClass(this.movedClass);
			}
			this.$.client.addChild(c);
			var p = this.$.client.hasNode();
			if (p && c.hasNode()) {
				var nextChild;
				var currIndex;
				for (var i = 0; i < this.$.client.children.length; i++) {
					var curr = this.$.client.children[i];
					if(curr.toolbarIndex !== undefined && curr.toolbarIndex != i) {
						nextChild = curr;
						currIndex = i;
						break;
					}
				}
				if (nextChild && nextChild.hasNode()) {
					c.insertNodeInParent(p, nextChild.node);
					var newChild = this.$.client.children.pop();
					this.$.client.children.splice(currIndex, 0, newChild);
				} else {
					c.appendNodeToParent(p);
				}
			}
			return true;
		}
	}
845106
def empty(self):
        """"""
        for k in list(self.children.keys()):
            self.remove_child(self.children[k])
1152827
function addChild (getValue, newChild, tree) {
    tree.children.splice(
      binaryIndexBy(getValue, getValue(newChild), tree.children),
      0, newChild
    );

    return newChild;
  }
617714
def _add_child(self, collection, set, child):
        """"""
        added = None
        for c in child:
            if c not in set:
                set.add(c)
                collection.append(c)
                added = 1
        if added:
            self._children_reset()
1021019
public void replaceChild(Node current, Node with) {
        double currentSplit = nodeSplits.get(current);
        int index = children.indexOf(current);
        children.remove(current);
        addChild(with, index, currentSplit);
        notifyStateChange();
    }
418643
private void addEmptyElements() {
        for (Node node : nodes) {
            boolean empty = true;
            if(node instanceof NestableNode) {
	            List<Node> nl = ((NestableNode) node).getChildren();
	            for (Node n : nl) {
	                if (n instanceof Element) {
	                    empty = false;
	                    break;
	                } else if (n instanceof Text) {
	                    // TODO: Should we trim the text and see if it's length 0?
	                    String value = ((Text) n).getContent();
	                    if (value.length() > 0) {
	                        empty = false;
	                        break;
	                    }
	                }
	            }
            }            
            if (empty) {
                result.add(node);
            }
        }
    }
496745
def add_children(self, children):
        
        if not isinstance(children, list):
            raise TypeError('"children" must be a list')
        for child in children:
            self.add_child(child)
164799
function () {
		var element = this.element,
			childNodes = element.childNodes,
			i = childNodes.length,
			node;

		while (i--) {
			node = childNodes[i];
			node.parentNode.removeChild(node);
		}
	}
1113538
function add(items) {
    var self = this;
    var children = self.get('children');
    if (Util.isArray(items)) {
      Util.each(items, function (item) {
        var parent = item.get('parent');
        if (parent) {
          parent.removeChild(item, false);
        }
        self._setCfgProperty(item);
      });
      self._cfg.children = children.concat(items);
    } else {
      var item = items;
      var parent = item.get('parent');
      if (parent) {
        parent.removeChild(item, false);
      }
      self._setCfgProperty(item);
      children.push(item);
    }
    return self;
  }