Check that a node can be casted to a vectorial node, in order to be able to use fancy indexing.
174739
def check_node_vectorisable(node):
        
        MESSAGE_PART_1 = "Cannot use fancy indexing on parameter node '{}', as"
        MESSAGE_PART_3 = "To use fancy indexing on parameter node, its children must be homogenous."
        MESSAGE_PART_4 = "See more at <https://openfisca.org/doc/coding-the-legislation/legislation_parameters#computing-a-parameter-that-depends-on-a-variable-fancy-indexing>."

        def raise_key_inhomogeneity_error(node_with_key, node_without_key, missing_key):
            message = " ".join([
                MESSAGE_PART_1,
                "'{}' exists, but '{}' doesn't.",
                MESSAGE_PART_3,
                MESSAGE_PART_4,
                ]).format(
                node._name,
                '.'.join([node_with_key, missing_key]),
                '.'.join([node_without_key, missing_key]),
                )

            raise ValueError(message)

        def raise_type_inhomogeneity_error(node_name, non_node_name):
            message = " ".join([
                MESSAGE_PART_1,
                "'{}' is a node, but '{}' is not.",
                MESSAGE_PART_3,
                MESSAGE_PART_4,
                ]).format(
                node._name,
                node_name,
                non_node_name,
                )

            raise ValueError(message)

        def raise_not_implemented(node_name, node_type):
            message = " ".join([
                MESSAGE_PART_1,
                "'{}' is a '{}', and fancy indexing has not been implemented yet on this kind of parameters.",
                MESSAGE_PART_4,
                ]).format(
                node._name,
                node_name,
                node_type,
                )
            raise NotImplementedError(message)

        def extract_named_children(node):
            return {
                '.'.join([node._name, key]): value
                for key, value in node._children.items()
                }

        def check_nodes_homogeneous(named_nodes):
            """
                Check than several nodes (or parameters, or baremes) have the same structure.
            """
            names = list(named_nodes.keys())
            nodes = list(named_nodes.values())
            first_node = nodes[0]
            first_name = names[0]
            if isinstance(first_node, ParameterNodeAtInstant):
                children = extract_named_children(first_node)
                for node, name in list(zip(nodes, names))[1:]:
                    if not isinstance(node, ParameterNodeAtInstant):
                        raise_type_inhomogeneity_error(first_name, name)
                    first_node_keys = first_node._children.keys()
                    node_keys = node._children.keys()
                    if not first_node_keys == node_keys:
                        missing_keys = set(first_node_keys).difference(node_keys)
                        if missing_keys:  # If the first_node has a key that node hasn't
                            raise_key_inhomogeneity_error(first_name, name, missing_keys.pop())
                        else:  # If If the node has a key that first_node doesn't have
                            missing_key = set(node_keys).difference(first_node_keys).pop()
                            raise_key_inhomogeneity_error(name, first_name, missing_key)
                    children.update(extract_named_children(node))
                check_nodes_homogeneous(children)
            elif isinstance(first_node, float) or isinstance(first_node, int):
                for node, name in list(zip(nodes, names))[1:]:
                    if isinstance(node, int) or isinstance(node, float):
                        pass
                    elif isinstance(node, ParameterNodeAtInstant):
                        raise_type_inhomogeneity_error(name, first_name)
                    else:
                        raise_not_implemented(name, type(node).__name__)

            else:
                raise_not_implemented(first_name, type(first_node).__name__)

        check_nodes_homogeneous(extract_named_children(node))
156822
def validate(self):
        
        try:
            assert self.kind == content_kinds.TOPIC, "Assumption Failed: Node is supposed to be a topic"
            return super(TopicNode, self).validate()
        except AssertionError as ae:
            raise InvalidNodeException("Invalid node ({}): {} - {}".format(ae.args[0], self.title, self.__dict__))
21664
private Iterable<YamlNode> cast(Iterable<Object> nodes) {
        return () -> new UnmodifiableIterator<YamlNode>() {
            private final Iterator<Object> iter = nodes.iterator();

            @Override
            public boolean hasNext() {
                return iter.hasNext();
            }

            @Override
            public YamlNode next() {
                return (YamlNode) iter.next();
            }
        };
    }
808374
private void normalizeNodeTypes(Node n) {
    normalizeBlocks(n);

    for (Node child = n.getFirstChild();
         child != null; child = child.getNext()) {
      // This pass is run during the CompilerTestCase validation, so this
      // parent pointer check serves as a more general check.
      checkState(child.getParent() == n);

      normalizeNodeTypes(child);
    }
  }
664456
def ensure_node(self, tokens: ParseResults) -> BaseEntity:
        """"""
        if MODIFIER in tokens:
            return self.ensure_node(tokens[TARGET])

        node = parse_result_to_dsl(tokens)
        self.graph.add_node_from_data(node)
        return node
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];
}
1310169
function shouldIgnoreNode (node) {
  return node.nodeType === TEXT_NODE
    || node.nodeType === COMMENT_NODE
    || node.nodeType === CDATA_NODE;
}
881373
function checkASTandNode(ast, node) {
  typeCheckObject(ast, 'ast');
  typeCheckObject(node, 'node');
  runValidator(ast, 'ast');
  runValidator(node, 'node');
}
612472
function acceptNode(node) {
  var parent = node.parentElement;
  var isMath = (parent && parent.getAttribute && parent.getAttribute('class')) ? parent.getAttribute('class').includes('katex') || parent.getAttribute('class').includes('MathJax') : false;
  return parent &&
         parent.nodeName !== 'SCRIPT' &&
         parent.nodeName !== 'STYLE' &&
         parent.nodeName !== 'CODE' &&
         parent.nodeName !== 'PRE' &&
         parent.nodeName !== 'SPAN' &&
         parent.nodeName !== 'D-HEADER' &&
         parent.nodeName !== 'D-BYLINE' &&
         parent.nodeName !== 'D-MATH' &&
         parent.nodeName !== 'D-CODE' &&
         parent.nodeName !== 'D-BIBLIOGRAPHY' &&
         parent.nodeName !== 'D-FOOTER' &&
         parent.nodeName !== 'D-APPENDIX' &&
         parent.nodeName !== 'D-FRONTMATTER' &&
         parent.nodeName !== 'D-TOC' &&
         parent.nodeType !== 8 && //comment nodes
         !isMath;
}
1136976
final void ensureNodeIndex(int nodeIndex) {
        if (!initialized)
            throw new AssertionError("The graph has not yet been initialized.");

        if (nodeIndex < nodeCount)
            return;

        long oldNodes = nodeCount;
        nodeCount = nodeIndex + 1;
        boolean capacityIncreased = nodes.ensureCapacity((long) nodeCount * nodeEntryBytes);
        if (capacityIncreased) {
            long newBytesCapacity = nodes.getCapacity();
            initNodeRefs(oldNodes * nodeEntryBytes, newBytesCapacity);
        }
    }
824382
function(node) {
            node = Y.Dom.get(node);
            if (!node) {
                return null;
            }

            return Y.Dom.getPreviousSiblingBy(node);
        }
738276
function getSiblingNode(node) {
  while (node) {
    if (node.nextSibling) {
      return node.nextSibling;
    }
    node = node.parentNode;
  }
}
410137
@Deprecated
    public static Node toNode(Object o) throws PageException {
	if (o instanceof XMLStruct) return ((XMLStruct) o).toNode();
	if (o instanceof Node) return (Node) o;
	throw new CasterException(o, "node");
    }
624902
function tryClassifyNode(node) {
                if (ts.isJSDocTag(node)) {
                    return true;
                }
                if (ts.nodeIsMissing(node)) {
                    return true;
                }
                var classifiedElementName = tryClassifyJsxElementName(node);
                if (!ts.isToken(node) && node.kind !== 244 /* JsxText */ && classifiedElementName === undefined) {
                    return false;
                }
                var tokenStart = node.kind === 244 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node);
                var tokenWidth = node.end - tokenStart;
                ts.Debug.assert(tokenWidth >= 0);
                if (tokenWidth > 0) {
                    var type = classifiedElementName || classifyTokenType(node.kind, node);
                    if (type) {
                        pushClassification(tokenStart, tokenWidth, type);
                    }
                }
                return true;
            }
1085925
public static boolean hasNativeWebContent(AccessibilityNodeInfoCompat node) {
        if (node == null) {
            return false;
        }

        if (!supportsWebActions(node)) {
            return false;
        }

        // ChromeVox does not have sub elements, so if the parent element also has web content
        // this cannot be ChromeVox.
        AccessibilityNodeInfoCompat parent = node.getParent();
        if (supportsWebActions(parent)) {
            if (parent != null) {
                parent.recycle();
            }
            return true;
        }

        if (parent != null) {
            parent.recycle();
        }

        // ChromeVox never has child elements
        return node.getChildCount() > 0;
    }
568235
function isImmutable(node) {
  if (t.isType(node.type, "Immutable")) return true;

  if (t.isLiteral(node)) {
    if (node.regex) {
      // regexs are mutable
      return false;
    } else {
      // immutable!
      return true;
    }
  } else if (t.isIdentifier(node)) {
    if (node.name === "undefined") {
      // immutable!
      return true;
    } else {
      // no idea...
      return false;
    }
  }

  return false;
}
3994
function(node) {
        var simple = true;
        for(var child=node.firstChild; child; child=child.nextSibling) {
            if(child.nodeType === 1) {
                simple = false;
                break;
            }
        }
        return simple;
    }