Detaches the node from its parent (if any) and changes its document to
this document. The node's subtree and attributes will remain attached,
but their document will be changed to this document.
341015
public Node adoptNode(Node node) {
        if (!(node instanceof NodeImpl)) {
            return null; // the API specifies this quiet failure
        }
        NodeImpl nodeImpl = (NodeImpl) node;
        switch (nodeImpl.getNodeType()) {
            case Node.ATTRIBUTE_NODE:
                AttrImpl attr = (AttrImpl) node;
                if (attr.ownerElement != null) {
                    attr.ownerElement.removeAttributeNode(attr);
                }
                break;

            case Node.DOCUMENT_FRAGMENT_NODE:
            case Node.ENTITY_REFERENCE_NODE:
            case Node.PROCESSING_INSTRUCTION_NODE:
            case Node.TEXT_NODE:
            case Node.CDATA_SECTION_NODE:
            case Node.COMMENT_NODE:
            case Node.ELEMENT_NODE:
                break;

            case Node.DOCUMENT_NODE:
            case Node.DOCUMENT_TYPE_NODE:
            case Node.ENTITY_NODE:
            case Node.NOTATION_NODE:
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
                        "Cannot adopt nodes of type " + nodeImpl.getNodeType());

            default:
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
                        "Unsupported node type " + node.getNodeType());
        }

        Node parent = nodeImpl.getParentNode();
        if (parent != null) {
            parent.removeChild(nodeImpl);
        }

        changeDocumentToThis(nodeImpl);
        notifyUserDataHandlers(UserDataHandler.NODE_ADOPTED, node, null);
        return nodeImpl;
    }
564517
def _detach(self, item):
        """"""
        to_detach = []
        children_det = []
        children_match = False
        match_found = False

        value = self.filtervar.get()
        txt = self.treeview.item(item, 'text').lower()
        if value in txt:
            match_found = True
        else:
            class_txt = self.treedata[item].get_class().lower()
            if value in class_txt:
                match_found = True

        parent = self.treeview.parent(item)
        idx = self.treeview.index(item)
        children = self.treeview.get_children(item)
        if children:
            for child in children:
                match, detach = self._detach(child)
                children_match = children_match | match
                if detach:
                    children_det.extend(detach)

        if match_found:
            if children_det:
                to_detach.extend(children_det)
        else:
            if children_match:
                if children_det:
                    to_detach.extend(children_det)
            else:
                to_detach.append((item, parent, idx))
        match_found = match_found | children_match
        return match_found, to_detach
1304468
function makeRemove(child, node) {
  // NOTE: Null values reduce hidden classes.
  return {
    type: 'REMOVE_NODE',
    content: null,
    fromIndex: child._mountIndex,
    fromNode: node,
    toIndex: null,
    afterNode: null
  };
}
368538
private void changeDocumentToThis(NodeImpl node) {
        Map<String, UserData> userData = node.document.getUserDataMapForRead(node);
        if (!userData.isEmpty()) {
            getUserDataMap(node).putAll(userData);
        }
        node.document = this;

        // change the document on all child nodes
        NodeList list = node.getChildNodes();
        for (int i = 0; i < list.getLength(); i++) {
            changeDocumentToThis((NodeImpl) list.item(i));
        }

        // change the document on all attribute nodes
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            NamedNodeMap attributes = node.getAttributes();
            for (int i = 0; i < attributes.getLength(); i++) {
                changeDocumentToThis((AttrImpl) attributes.item(i));
            }
        }
    }
941755
def swap_with node
      return self if node.equal? self
      if self.attached?
        if node.attached?
          # both attached -- use placeholder
          placeholder = Default.new
          my_parent = @parent
          my_parent.replace_node(self, placeholder)
          node.parent.replace_node(node, self)
          my_parent.replace_node(placeholder, node)
        else
          # only `self' attached
          @parent.replace_node(self, node)
        end
      else
        if node.attached?
          # only `node' attached
          node.parent.replace_node(node, self)
        else
          # neither attached -- nothing to do
        end
      end
      return self
    end
676791
function () {
      this.removeChildInstances();

      if (this.template) {
        // temporarily assign a new node to get the content in a doc fragment
        this.vscope=this.parent.vscope; // to come back to original state, when the scope has not been changed by the template
        var targs=this.getTemplateArguments(), cargs=this.getCptArguments();
        var realNode = this.node;
        var df = doc.createDocumentFragment();
        this.node = df;
        this.template.call(this, targs, cargs); // WARNING: this changes vscope to the template vscope

        realNode.insertBefore(df, this.node2);
        this.replaceNodeBy(df , realNode); // recursively remove doc fragment reference
        // now this.node=realNode
        this.isDOMempty = false;
      }
  }
954927
def remove(self, node):
        
        if node is None or node._prev == -1:
            return
        if node._next is None:
            self._last = node._prev  # last node
        else:
            node._next._prev = node._prev
        if node._prev is None:
            self._first = node._next  # first node
        else:
            node._prev._next = node._next
        node._prev = node._next = -1
        self._size -= 1
1144539
@Override
    public ComponentType detach() {
        synchronized (this) {
            if (parent != null) {
                ComponentVertex oldParent = parent;
                synchronized (tree) {
                    if (!tree.isStarted()) {
                        throw new IllegalStateException(
                            "Components may not be detached from a tree before"
                                + " a Start event has been fired on it.");
                    }
                    synchronized (oldParent) {
                        parent.children.remove(this);
                        parent.tree.clearHandlerCache();
                        parent = null;
                    }
                    ComponentTree newTree = new ComponentTree(this);
                    newTree.setEventPipeline(new FeedBackPipelineFilter(
                        new EventProcessor(newTree)));
                    setTree(newTree);
                }
                Detached evt = new Detached(component(), oldParent.component());
                oldParent.fire(evt);
                evt = new Detached(component(), oldParent.component());
                fire(evt);
            }
            return component();
        }
    }
994916
def removeChild(self, child):
		
		for i, childNode in enumerate(self.childNodes):
			if childNode is child:
				del self.childNodes[i]
				child.parentNode = None
				return child
		raise ValueError(child)
533601
def copyNode(node, children=False, parent=False):
    
    if parent is not False:
        element = SubElement(
            parent,
            node.tag,
            attrib=node.attrib,
            nsmap={None: "http://www.tei-c.org/ns/1.0"}
        )
    else:
        element = Element(
            node.tag,
            attrib=node.attrib,
            nsmap={None: "http://www.tei-c.org/ns/1.0"}
        )
    if children:
        if node.text:
            element._setText(node.text)
        for child in xmliter(node):
            element.append(copy(child))
    return element
1091268
protected Node removeNode( Node node )
    {
        // Remove node.
        node.previous.next = node.next;
        node.next.previous = node.previous;
        node.removed = true;
        return node;
    }
85386
function remove(node, isRemoveChild) {
  if (!node || !node.parentNode) { return; }
  if (node.removeNode) { return node.removeNode(isRemoveChild); }

  const parent = node.parentNode;
  if (!isRemoveChild) {
    const nodes = [];
    for (let i = 0, len = node.childNodes.length; i < len; i++) {
      nodes.push(node.childNodes[i]);
    }

    for (let i = 0, len = nodes.length; i < len; i++) {
      parent.insertBefore(nodes[i], node);
    }
  }

  parent.removeChild(node);
}
304176
public void remove(int node) {
        if (node == NIL) {
            throw new IllegalArgumentException();
        }
        if (left(node) != NIL && right(node) != NIL) {
            // inner node
            final int next = next(node);
            assert next != NIL;
            swap(node, next);
        }
        assert left(node) == NIL || right(node) == NIL;

        final int parent = parent(node);
        int child = left(node);
        if (child == NIL) {
            child = right(node);
        }

        if (child == NIL) {
            // no children
            if (node == root) {
                assert size() == 1 : size();
                root = NIL;
            } else {
                if (node == left(parent)) {
                    left(parent, NIL);
                } else {
                    assert node == right(parent);
                    right(parent, NIL);
                }
            }
        } else {
            // one single child
            if (node == root) {
                assert size() == 2;
                root = child;
            } else if (node == left(parent)) {
                left(parent, child);
            } else {
                assert node == right(parent);
                right(parent, child);
            }
            parent(child, parent);
        }

        release(node);
        rebalance(parent);
    }
513169
function () {
        var self = this, node, i = this.length;

        while (i--) {
          node = self[i];
          Event.clean(node);

          if (node.parentNode) {
            node.parentNode.removeChild(node);
          }
        }

        return this;
      }
1255714
private void adaptForRemove(final ITreeStructData pOldNode) throws TTException {
        assert pOldNode != null;

        // Adapt left sibling node if there is one.
        if (pOldNode.hasLeftSibling()) {
            final ITreeStructData leftSibling = (ITreeStructData)getPtx().getData(pOldNode.getLeftSiblingKey());
            leftSibling.setRightSiblingKey(pOldNode.getRightSiblingKey());
            getPtx().setData(leftSibling);
        }

        // Adapt right sibling node if there is one.
        if (pOldNode.hasRightSibling()) {
            final ITreeStructData rightSibling = (ITreeStructData)getPtx().getData(pOldNode.getRightSiblingKey());
            rightSibling.setLeftSiblingKey(pOldNode.getLeftSiblingKey());
            getPtx().setData(rightSibling);
        }

        // Adapt parent, if node has now left sibling it is a first child.
        final ITreeStructData parent = (ITreeStructData)getPtx().getData(pOldNode.getParentKey());
        if (!pOldNode.hasLeftSibling()) {
            parent.setFirstChildKey(pOldNode.getRightSiblingKey());
        }
        parent.decrementChildCount();
        getPtx().setData(parent);

        if (pOldNode.getKind() == IConstants.ELEMENT) {
            // removing attributes
            for (int i = 0; i < ((ElementNode)pOldNode).getAttributeCount(); i++) {
                moveTo(((ElementNode)pOldNode).getAttributeKey(i));
                getPtx().removeData(mDelegate.getCurrentNode());
            }
            // removing namespaces
            moveTo(pOldNode.getDataKey());
            for (int i = 0; i < ((ElementNode)pOldNode).getNamespaceCount(); i++) {
                moveTo(((ElementNode)pOldNode).getNamespaceKey(i));
                getPtx().removeData(mDelegate.getCurrentNode());
            }
        }

        // Remove old node.
        getPtx().removeData(pOldNode);
    }
515162
public boolean removeChild(Node node) throws ChildNodeException {
    Node currNode = getFirstChild();
    boolean rc = false;

    if (!allowChildren) {
      throw new ChildNodeException();
    }

    if (node != null && !isLeaf()) {
      // Is this the first and only child
      if (node == currNode && node == currNode.getNextSibling()) {
        setFirstChild(null);
        rc = true;
      } else {
        // Verify that this Node is a child here
        do {
          if (currNode == node) {
            // Remove this child
            if (node.getPrevSibling() != null) {
              node.getPrevSibling().setNextSibling(node.getNextSibling());
            }
            if (node == getFirstChild()) {
              setFirstChild(node.getNextSibling());
            }

            rc = true;

            // do not release. Item.resolve expects the 
            // pointers to be intact after a remove
            //node.release();
            break;
          }
          currNode = currNode.getNextSibling();
        } while (currNode != getFirstChild());
      }
    }

    return rc;
  }
1205184
function () {
            if (!el) {
                return;
            }

            if (el.nodeType === NODE_TYPE.TEXT_NODE) {
                while (el.nextSibling && el.nextSibling.nodeType === NODE_TYPE.TEXT_NODE) {
                    el.nodeValue += el.nextSibling.nodeValue;
                    el.parentNode.removeChild(el.nextSibling);
                }
            } else {
                dom(el.firstChild).normalizeTextNodes();
            }
            dom(el.nextSibling).normalizeTextNodes();
        }