Resolve a single node or all when node is omitted.
6287
def resolve_node(self, node=None, resolved=None, seen=None):
        
        if seen is None:
            seen = []
        if resolved is None:
            resolved = []
        if node is None:
            dependencies = sorted(self._nodes.keys())
        else:
            dependencies = self._nodes[node]
            seen.append(node)
        for dependency in dependencies:
            if dependency in resolved:
                continue
            if dependency in seen:
                raise Exception('Circular dependency %s > %s', str(node),
                                str(dependency))
            self.resolve_node(dependency, resolved, seen)
        if node is not None:
            resolved.append(node)
        return resolved
206400
Node tryFoldEmptyDo(Node n) {
    checkArgument(n.isDo());

    Node body = NodeUtil.getLoopCodeBlock(n);
    if (body.isBlock() && !body.hasChildren()) {
      Node cond = NodeUtil.getConditionExpression(n);
      Node forNode =
          IR.forNode(IR.empty().srcref(n),
                     cond.detach(),
                     IR.empty().srcref(n),
                     body.detach());
      n.replaceWith(forNode);
      reportChangeToEnclosingScope(forNode);
      return forNode;
    }
    return n;
  }
806865
function isPreviousLineEmpty(text, node, locStart) {
  let idx = locStart(node) - 1;
  idx = skipSpaces(text, idx, { backwards: true });
  idx = skipNewline(text, idx, { backwards: true });
  idx = skipSpaces(text, idx, { backwards: true });
  const idx2 = skipNewline(text, idx, { backwards: true });
  return idx !== idx2;
}
297578
def ignore_whitespace_text_nodes(cls, wrapped_node):
        
        for child in wrapped_node.children:
            if child.is_text and child.value.strip() == '':
                child.delete()
            else:
                cls.ignore_whitespace_text_nodes(child)
770911
def noEmptyNests(node): 
    ''' '''
    if type(node)==list:
        for i in node:
            noEmptyNests(i)
    if type(node)==dict:
        for i in node.values():
            noEmptyNests(i)
        if node["children"] == []:
            node.pop("children")
    return node
1025507
function fallbackResolve(path, root) {
  let steps = path.split("/")
  let node = root
  while (node) {
    let step = steps.shift()
    if (step === undefined) break
    if (step === '.') continue
    let [name, position] = step.split(/[\[\]]/)
    name = name.replace('_default_:', '')
    position = position ? parseInt(position) : 1
    node = findChild(node, name, position)
  }
  return node
}
657449
private void initHeadTail(Node<E> h, Node<E> t) {
        if (h == t) {
            if (h == null)
                h = t = new Node<E>();
            else {
                // Avoid edge case of a single Node with non-null item.
                Node<E> newNode = new Node<E>();
                NEXT.set(t, newNode);
                PREV.set(newNode, t);
                t = newNode;
            }
        }
        head = h;
        tail = t;
    }
1103431
def _extract(node, name, index=0):
    """"""

    nodes = node.getElementsByTagName(name)

    if len(nodes):
        if nodes[index].firstChild:
            return _unescape_htmlentity(nodes[index].firstChild.data.strip())
    else:
        return None
1326966
function one(node) {
    var children = node.children
    var length = children.length
    var index = -1
    var values = []
    var words = []
    var child
    var tags

    while (++index < length) {
      child = children[index]

      if (child.type === 'WordNode') {
        values.push(toString(child))
        words.push(child)
      }
    }

    tags = tagger.tag(values)
    index = -1
    length = tags.length

    while (++index < length) {
      patch(words[index], tags[index][1])
    }
  }
169791
def unimplemented(self, node):
        """"""
        self.raise_exception(node, exc=NotImplementedError,
                             msg="'%s' not supported" %
                             (node.__class__.__name__))
375374
def post_cleanup(self):
        
        targetNode = self.article.top_node
        node = self.add_siblings(targetNode)
        for e in self.parser.getChildren(node):
            e_tag = self.parser.getTag(e)
            if e_tag != 'p':
                if self.is_highlink_density(e) \
                    or self.is_table_and_no_para_exist(e) \
                    or not self.is_nodescore_threshold_met(node, e):
                    self.parser.remove(e)
        return node
1029923
protected function resolve(Node $node)
    {
        $value = null;
        try {
            ++$this->nodeLevel;

            $methodName = $this->getDispatchMethodFor($node);
            if (method_exists($this, $methodName)) {
                $value = $this->$methodName($node);
            }
        } finally {
            --$this->nodeLevel;
        }

        return $value;
    }
1298099
private Node getLastChild(Node node) {

		if (node == null)
			return null;

		Node newNode = node.getLastChild();
		if (newNode == null)
			return null;

		int accept = acceptNode(newNode);
		if (accept == NodeFilter.FILTER_ACCEPT)
			return newNode;
		else if (accept == NodeFilter.FILTER_SKIP && newNode.hasChildNodes())
			return getLastChild(newNode);

		// if (accept == NodeFilter.REJECT_NODE)
		return getPreviousSibling(newNode);

	}
1042776
function fixParagraphNode(node, fullText) {
    const firstNode = node.children[0];
    const lastNode = node.children[node.children.length - 1];
    node.range = [firstNode.range[0], lastNode.range[1]];
    node.raw = fullText.slice(node.range[0], node.range[1]);
    node.loc = {
        start: {
            line: firstNode.loc.start.line,
            column: firstNode.loc.start.column
        },
        end: {
            line: lastNode.loc.end.line,
            column: lastNode.loc.end.column
        }
    };
}
1281643
private void fix(Node<K, V> x) {
    if (x == null) {
      return;
    }
    x.N = 1 + size(x.left) + size(x.right);
    x.max = max3(x.interval.hi, max(x.left), max(x.right));
  }
1261609
final Node<E> succ(Node<E> p) {
        // TODO: should we skip deleted nodes here?
        if (p == (p = p.next))
            p = first();
        return p;
    }
1326563
def resolve_nodes(self, nodes):
        
        if not nodes:
            return []
        resolved = []
        for node in nodes:
            if node in resolved:
                continue
            self.resolve_node(node, resolved)
        return resolved