Replace `node' with `newnode'.
491002
def replace_node(node, newnode=nil)
      node.parent.equal? self or
        raise ArgumentError, "node is not a child"
      field = node.instance_variable_get(:@parent_field)
      self.send(field.writer, newnode)
      return self
    end
497741
def _append(self, node, contents):
        """"""
        if isinstance(contents, basestring):
            if contents != '':
                if len(node) == 0:
                    if node.text is None:
                        node.text = contents
                    else:
                        node.text += contents
                else:
                    last = node[-1]
                    if last.tail is None:
                        last.tail = contents
                    else:
                        last.tail += contents
        elif et.iselement(contents):
            contents.tail = ''
            node.append(contents)
        else:
            try:
                for content in contents:
                    self._append(node, content)
            except TypeError:
                self._append(node, self._format(contents))
1334283
def prepend(self, *nodes: Union[str, AbstractNode]) -> None:
        """"""
        node = _to_node_list(nodes)
        if self.firstChild:
            self.insertBefore(node, self.firstChild)
        else:
            self.appendChild(node)
123619
def visit_dict(self, node, parent):
        """"""
        newnode = nodes.Dict(node.lineno, node.col_offset, parent)
        items = list(self._visit_dict_items(node, parent, newnode))
        newnode.postinit(items)
        return newnode
47646
def subnode(self, node):
        """"""
        self.children.append(node)
        node.parent = self
        node.adjust_interleave(node.interleave)
980853
def visit_keyword(self, node, parent):
        """"""
        newnode = nodes.Keyword(node.arg, parent=parent)
        newnode.postinit(self.visit(node.value, newnode))
        return newnode
800472
def mutate(self, node, index):
        """"""
        assert index == 0
        assert isinstance(node, ForStmt)

        empty_list = parso.parse(' []')
        node.children[3] = empty_list
        return node
646801
def copy_location(new_node, old_node):
    
    for attr in 'lineno', 'col_offset':
        if attr in old_node._attributes and attr in new_node._attributes \
           and hasattr(old_node, attr):
            setattr(new_node, attr, getattr(old_node, attr))
    return new_node
721188
def replace_function_node(node, annotation):
    
    target, funcs = parse_nni_function(annotation)
    FuncReplacer(funcs, target).visit(node)
    return node
425325
function replaceNewlines (elem) {
  var node = elem.firstChild,
      depth = 0,
      br

  while (node) {
    if (node.nodeType === Node.ELEMENT_NODE) {

      if (node.firstChild) {
        depth += 1
        node = node.firstChild
      }
      else node = node.nextSibling

      continue
    }

    if (/\n/.test(node.data)) {
      node.splitText(node.data.indexOf('\n') + 1)

      br = node.splitText(node.data.length - 1)

      // We now have a lone text with \n as data.
      // Replace it with a <br>
      br.parentNode.replaceChild(document.createElement('br'), br)

      node = node.nextSibling
    }

    while (!node.nextSibling) {
      if (!depth) break

      depth -= 1
      node = node.parentNode
    }

    node = node.nextSibling
  }
}
218904
def visit_delete(self, node, parent):
        """"""
        newnode = nodes.Delete(node.lineno, node.col_offset, parent)
        newnode.postinit([self.visit(child, newnode) for child in node.targets])
        return newnode
416756
def replaceWith(self, *nodes: Union[AbstractNode, str]) -> None:
        
        if self.parentNode:
            node = _to_node_list(nodes)
            self.parentNode.replaceChild(node, self)
738246
def add_node(self, node):
        
        if node.id in self.nodes:
            del self.nodes[node.id]
            self.nodes[node.id] = node
        elif len(self) < self.ksize:
            self.nodes[node.id] = node
        else:
            if node.id in self.replacement_nodes:
                del self.replacement_nodes[node.id]
            self.replacement_nodes[node.id] = node
            return False
        return True
223450
def visit_lambda(self, node, parent):
        """"""
        newnode = nodes.Lambda(node.lineno, node.col_offset, parent)
        newnode.postinit(self.visit(node.args, newnode), self.visit(node.body, newnode))
        return newnode
1323891
function replace(node, nodeName) {
  if (node.nodeName.toUpperCase() === nodeName.toUpperCase()) {
    return node;
  }

  const newNode = create(nodeName);

  if (node.style.cssText) {
    newNode.style.cssText = node.style.cssText;
  }

  appendChildNodes(newNode, lists.from(node.childNodes));
  insertAfter(newNode, node);
  remove(node);

  return newNode;
}
1310672
def add_node(self, node):
        """"""
        self.nodes.append(node)

        # add node_ids
        try:
            if node.node_id != b"$stats":
                self.node_ids.append(node.node_id)
        except NotImplementedError:
            raise
        except Exception:
            print("ERROR: getting Node")
583371
public void replaceWith(Node in) {
        Validate.notNull(in);
        Validate.notNull(parentNode);
        parentNode.replaceChild(this, in);
    }