Traversal function for the "following-sibling" direction
          The following-sibling axis contains the following siblings
           of the context node in document order.
436948
def xpathNextFollowingSibling(self, cur):
        
        if cur is None: cur__o = None
        else: cur__o = cur._o
        ret = libxml2mod.xmlXPathNextFollowingSibling(self._o, cur__o)
        if ret is None:raise xpathError('xmlXPathNextFollowingSibling() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
1236473
def siblings(client, revision, paths):
    """"""
    graph = Graph(client)
    nodes = graph.build(paths=paths, revision=revision)
    siblings_ = set(nodes)
    for node in nodes:
        siblings_ |= graph.siblings(node)

    paths = {node.path for node in siblings_}
    for path in paths:
        click.echo(graph._format_path(path))
826281
function getSibling(node, relativeIndex) {
  var parent = node.parentNode;
  if (parent === null) {
    return null;
  }
  var currentIndex = parent.childNodes.indexOf(node);
  var siblingIndex = currentIndex + relativeIndex;
  if (siblingIndex < 0 || siblingIndex > parent.childNodes.length - 1) {
    return null;
  }
  return parent.childNodes[siblingIndex];
}
84136
def with_siblings(graph, outputs):
    """"""
    siblings = set()
    for node in outputs:
        siblings |= graph.siblings(node)
    return siblings
829685
def toposort(graph, pick_first='head'):
    
    in_deg = {}
    for node, next_nodes in six.iteritems(graph):
        for next_node in [next_nodes.head_node, next_nodes.update_node]:
            if next_node is None:
                continue
            in_deg[next_node] = in_deg.get(next_node, 0) + 1

    stk = [FIRST]
    ordered = []
    visited = set()
    while stk:
        node = stk.pop()
        visited.add(node)
        if node != FIRST:
            ordered.append(node)
        traversal = _get_traversal(graph.get(node, BeforeNodes()), pick_first)
        for next_node in traversal:
            if next_node is None:
                continue
            if next_node in visited:
                raise ValueError('Graph has a cycle')

            in_deg[next_node] -= 1
            if in_deg[next_node] == 0:
                stk.append(next_node)

    # Nodes may not be walked because they don't reach in degree 0.
    if len(ordered) != len(graph) - 1:
        raise ValueError('Graph has a cycle')
    return ordered
873200
def get_siblings(self):
        
        qset = get_result_class(self.__class__).objects.filter(
            depth=self.depth
        ).order_by(
            'path'
        )
        if self.depth > 1:
            # making sure the non-root nodes share a parent
            parentpath = self._get_basepath(self.path, self.depth - 1)
            qset = qset.filter(
                path__range=self._get_children_path_interval(parentpath))
        return qset
673615
function findFirstTextNode(node) {
          var walker;

          if (node) {
            walker = new TreeWalker(node, node);

            for (node = walker.current(); node; node = walker.next()) {
              if (node.nodeType === 3) {
                return node;
              }
            }
          }
        }
583232
function walk(node, rootNode, prev) {
      var sibling, parent, startName = prev ? 'lastChild' : 'firstChild', siblingName = prev ? 'prev' : 'next';

      // Walk into nodes if it has a start
      if (node[startName]) {
        return node[startName];
      }

      // Return the sibling if it has one
      if (node !== rootNode) {
        sibling = node[siblingName];

        if (sibling) {
          return sibling;
        }

        // Walk up the parents to look for siblings
        for (parent = node.parent; parent && parent !== rootNode; parent = parent.parent) {
          sibling = parent[siblingName];

          if (sibling) {
            return sibling;
          }
        }
      }
    }
997915
function getPreviousSiblings(el) {
  var siblings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  var previousSibling = el.previousSibling;

  if (!previousSibling) {
    return siblings;
  }

  siblings.push(previousSibling);
  return getPreviousSiblings(previousSibling, siblings);
}
722854
function findTextNodeRelative(left, startNode) {
            var walker, lastInlineElement, parentBlockContainer;

            startNode = startNode || container;
            parentBlockContainer = dom.getParent(startNode.parentNode, dom.isBlock) || body;

            // Lean left before the BR element if it's the only BR within a block element. Gecko bug: #6680
            // This: <p><br>|</p> becomes <p>|<br></p>
            if (left && startNode.nodeName == 'BR' && isAfterNode && dom.isEmpty(parentBlockContainer)) {
              container = startNode.parentNode;
              offset = dom.nodeIndex(startNode);
              normalized = true;
              return;
            }

            // Walk left until we hit a text node we can move to or a block/br/img
            walker = new TreeWalker(startNode, parentBlockContainer);
            while ((node = walker[left ? 'prev' : 'next']())) {
              // Break if we hit a non content editable node
              if (dom.getContentEditableParent(node) === "false" || isCeFalseCaretContainer(node, dom.getRoot())) {
                return;
              }

              // Found text node that has a length
              if (node.nodeType === 3 && node.nodeValue.length > 0) {
                if (hasParentWithName(node, body, 'A') === false) {
                  container = node;
                  offset = left ? node.nodeValue.length : 0;
                  normalized = true;
                }

                return;
              }

              // Break if we find a block or a BR/IMG/INPUT etc
              if (dom.isBlock(node) || nonEmptyElementsMap[node.nodeName.toLowerCase()]) {
                return;
              }

              lastInlineElement = node;
            }

            // Only fetch the last inline element when in caret mode for now
            if (collapsed && lastInlineElement) {
              container = lastInlineElement;
              normalized = true;
              offset = 0;
            }
          }
497378
function (start) {
        var container, parent, sibling, siblingName, root;

        container = parent = start ? startContainer : endContainer;
        siblingName = start ? 'previousSibling' : 'nextSibling';
        root = dom.getRoot();

        // If it's a text node and the offset is inside the text
        if (container.nodeType === 3 && !isWhiteSpaceNode(container)) {
          if (start ? startOffset > 0 : endOffset < container.nodeValue.length) {
            return container;
          }
        }

        /*eslint no-constant-condition:0 */
        while (true) {
          // Stop expanding on block elements
          if (!format[0].block_expand && dom.isBlock(parent)) {
            return parent;
          }

          // Walk left/right
          for (sibling = parent[siblingName]; sibling; sibling = sibling[siblingName]) {
            if (!isBookmarkNode(sibling) && !isWhiteSpaceNode(sibling) && !isBogusBr(sibling)) {
              return parent;
            }
          }

          // Check if we can move up are we at root level or body level
          if (parent === root || parent.parentNode === root) {
            container = parent;
            break;
          }

          parent = parent.parentNode;
        }

        return container;
      }
1242871
private boolean isForwardAxis() {

        final String content = mToken.getContent();
        return (mToken.getType() == TokenType.TEXT && ("child".equals(content) || ("descendant"
            .equals(content)
            || "descendant-or-self".equals(content)
            || "attribute".equals(content)
            || "self".equals(content)
            || "following".equals(content) || "following-sibling".equals(content) || "namespace"
                .equals(content))));
    }
257985
def nextElementSibling(self) -> Optional[AbstractNode]:
        
        if self.parentNode is None:
            return None
        siblings = self.parentNode.childNodes
        for i in range(siblings.index(self) + 1, len(siblings)):
            n = siblings[i]
            if n.nodeType == Node.ELEMENT_NODE:
                return n
        return None
420492
def horizontal_positions(docgraph, sentence_root=None):
    """"""
    # calculate positions for the whole graph
    root_cond = (sentence_root is None) or (sentence_root == docgraph.root)
    if root_cond or ('tokens' not in docgraph.node[sentence_root]):
        sentence_root = docgraph.root
        token_nodes = docgraph.tokens
        path = {}
    else:  # calculate positions only for the given sentence subgraph
        token_nodes = docgraph.node[sentence_root]['tokens']
        path = {sentence_root: 0}

    for i, token_node in enumerate(token_nodes):
        start_node = token_node
        while get_parents(docgraph, start_node, strict=True):
            if start_node not in path:
                path[start_node] = i
            start_node = get_parents(docgraph, start_node, strict=True)[0]
    return path
105835
QNode traversalHead() {
    for (;;) {
      QNode t = this.tail.get();
      QNode h = this.head.get();
      if (h != null && t != null) {
        QNode last = t.next;
        QNode first = h.next;
        if (t == this.tail.get()) {
          if (last != null) {
            this.tail.compareAndSet(t, last);
          } else if (first != null) {
            Object x = first.get();
            if (x == first) {
              advanceHead(h, first);
            } else {
              return h;
            }
          } else {
            return h;
          }
        }
      }
    }
  }
300524
function traverseBreadthFirst(rootNode, options) {
  options = extend({
    subnodesAccessor: function(node) { return node.subnodes; },
    userdataAccessor: function(node, userdata) { return userdata; },
    onNode: function(node, callback, userdata) { callback(); },
    onComplete: function(rootNode) {},
    userdata: null
  }, options);

  var queue = [];
  queue.push([rootNode, options.userdata]);

  (function next() {
    if (queue.length == 0) {
      options.onComplete(rootNode);
      return;
    }

    var front = queue.shift();
    var node = front[0];
    var data = front[1];

    options.onNode(node, function() {
      var subnodeData = options.userdataAccessor(node, data);
      var subnodes = options.subnodesAccessor(node);
      async.eachSeries(subnodes,
        function(subnode, nextNode) {
          queue.push([subnode, subnodeData]);
          async.setImmediate(nextNode);
        },
        function() {
          async.setImmediate(next);
        }
      );
    },
    data);
  })();
}
1259800
function adjacent(node, selector, ancestry) {
            var parent = ancestry[0], listProp, keys, i, l, idx;
            if (!parent) { return false; }
            keys = estraverse.VisitorKeys[parent.type];
            for (i = 0, l = keys.length; i < l; ++i) {
                listProp = parent[keys[i]];
                if (isArray(listProp)) {
                    idx = listProp.indexOf(node);
                    if (idx < 0) { continue; }
                    if (idx > 0 && matches(listProp[idx - 1], selector, ancestry)) {
                        return true;
                    }
                    if (idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) {
                        return true;
                    }
                }
            }
            return false;
        }