Iterate over nodes that are equivalent to the given node, including the original.
964220
def iter_equivalent_nodes(self, node: BaseEntity) -> Iterable[BaseEntity]:
        """"""
        yield node
        yield from self._equivalent_node_iterator_helper(node, {node})
941699
def nodes(self) -> iter:
        """"""
        yield from (elem for elem, subs in self.inclusions.items() if subs == ())
120477
def iter_children(graph, node: BaseEntity) -> Iterable[BaseEntity]:
    """"""
    return (
        node
        for node, _, d in graph.in_edges(node, data=True)
        if d[RELATION] == IS_A
    )
69856
def copy_node(node):
  """"""
  if not isinstance(node, gast.AST):
    return [copy_node(n) for n in node]
  new_node = copy.deepcopy(node)
  setattr(new_node, anno.ANNOTATION_FIELD,
          getattr(node, anno.ANNOTATION_FIELD, {}).copy())
  return new_node
751776
def replace(self, new_node):
        """"""
        cur_node = self.cur_node
        nodestack = self.nodestack
        cur = nodestack.pop()
        prev = nodestack[-1]
        index = prev[-1] - 1
        oldnode, name = prev[-2][index]
        assert cur[0] is cur_node is oldnode, (cur[0], cur_node, prev[-2],
                                               index)
        parent = prev[0]
        if isinstance(parent, list):
            parent[index] = new_node
        else:
            setattr(parent, name, new_node)
160016
def visit_Set(self, node: ast.Set) -> Set[Any]:
        """"""
        result = set(self.visit(node=elt) for elt in node.elts)

        self.recomputed_values[node] = result
        return result
266423
def are_equivalent(a_xml, b_xml, encoding=None):
    
    assert isinstance(a_xml, str)
    assert isinstance(b_xml, str)
    a_tree = str_to_etree(a_xml, encoding)
    b_tree = str_to_etree(b_xml, encoding)
    return are_equal_or_superset(a_tree, b_tree) and are_equal_or_superset(
        b_tree, a_tree
    )
96652
def visit_Attribute(self, node: ast.Attribute) -> None:
        """"""
        if node in self._recomputed_values:
            value = self._recomputed_values[node]

            if _representable(value=value):
                text = self._atok.get_text(node)
                self.reprs[text] = value

        self.generic_visit(node=node)
487095
def from_node(cls, node):
        """"""
        kwargs = dict(
            node_id=node.node_id,
            node_finalized=node.finalized,
            node_history=list(node.history),
            node_name=node.name,
            node_class=node.__class__.__name__,
            node_status=str(node.status),
        )

        return node.Results(node, **kwargs)
231463
def nodes(self):
        """"""
        getnode = self._nodes.__getitem__
        return [getnode(nid) for nid in self._nodeids]
1101449
function cloneDeep(node) {
  var newNode = {};

  for (var key in node) {
    if (key[0] === "_") continue;

    var val = node[key];

    if (val) {
      if (val.type) {
        val = t.cloneDeep(val);
      } else if (Array.isArray(val)) {
        val = val.map(t.cloneDeep);
      }
    }

    newNode[key] = val;
  }

  return newNode;
}
947893
Node cloneProps(Node n) {
    if (!n.hasProps()) {
      n.clonePropsFrom(templateNode);
    }
    for (Node child : n.children()) {
      cloneProps(child);
    }
    return n;
  }
21094
def ind_nodes(self, graph=None):
        
        if graph is None:
            graph = self.graph

        dependent_nodes = set(
            node for dependents in six.itervalues(graph) for node in dependents
        )
        return [node for node in graph.keys() if node not in dependent_nodes]
821853
def clone(self):
        """"""
        return Node(self.type, [ch.clone() for ch in self.children],
                    fixers_applied=self.fixers_applied)
1187373
def apply(self):
        """"""
        # In this phase, we look for hyperlinks (references nodes)
        # that contain substitutions (of the form "|foo|").
        # We then add actual "substitution"s nodes to those references,
        # so that they can be replaced by the substitution processor.
        subst_re = re.compile(self.subst_pattern)

        for link in self.document.traverse(self._maybe_hyperlink):
            if 'refuri' not in link:
                continue

            # Note: "target" nodes do not have a "name" attribute.
            if '|' not in link['refuri'] and '|' not in link.get('name', ''):
                continue

            # This list acts as a cache so that only one substitution node
            # is added as a child for each substitution name.
            substitutions = []

            matches = subst_re.findall(link['refuri']) + \
                subst_re.findall(link.get('name', ''))
            for subref_text in matches:
                if subref_text in substitutions:
                    continue

                substitutions.append(subref_text)
                subref_node = nodes.substitution_reference(subref_text)
                link.append(subref_node)
                self.document.note_substitution_ref(subref_node, subref_text)

            # Build a map of substitutions names to child indices
            # (minus one since the actual link label is in link[0]).
            link['varlinks'] = \
                dict(zip(substitutions, range(len(substitutions))))
432817
def visit_expr(self, node, parent):
        """"""
        newnode = nodes.Expr(node.lineno, node.col_offset, parent)
        newnode.postinit(self.visit(node.value, newnode))
        return newnode
442256
def _equivalent_node_iterator_helper(self, node: BaseEntity, visited: Set[BaseEntity]) -> BaseEntity:
        """"""
        for v in self[node]:
            if v in visited:
                continue

            if self._has_no_equivalent_edge(node, v):
                continue

            visited.add(v)
            yield v
            yield from self._equivalent_node_iterator_helper(v, visited)