Iterates over all the directives for a node and returns index of a directive for a given type.

@param node Node on which directives are present.
@param type Type of a directive to look for.
@returns Index of a found directive or null when none found.
508998
function getIdxOfMatchingDirective(node, type) {
    var defs = node.view[TVIEW].directives;
    var flags = node.tNode.flags;
    var count = flags & 4095 /* DirectiveCountMask */;
    var start = flags >> 14 /* DirectiveStartingIndexShift */;
    var end = start + count;
    for (var i = start; i < end; i++) {
        var def = defs[i];
        if (def.type === type && def.diPublic) {
            return i;
        }
    }
    return null;
}
629797
@Override
    protected void indexNode(Node node, EntityMetadata entityMetadata)
    {
        super.indexNode(node, entityMetadata);

        // Write to inverted index table if applicable
        invertedIndexHandler.write(node, entityMetadata, getPersistenceUnit(), getConsistencyLevel(), dataHandler);
    }
1095576
function getNthElementOfType(context, element, index) {
  let nthOfType = 0;
  for (let i = 0, child; (child = context.children[i]); i++) {
    if (child.nodeType === child.ELEMENT_NODE &&
        child.tagName.toLowerCase() === element.tagName.toLowerCase()) {
      if (nthOfType === index) {
        return child;
      }
      nthOfType++;
    }
  }
  return null;
}
676688
private function getNodeIndex( $node )
	{
		for( $i=0; $i<$this->count(); $i++ )
			if( $this->nodes[$i] == $node )
				return $i;
		return NULL;
	}
476173
function getNodeIndex(node) {
	var ret = 0;
	while (node.previousSibling) {
		ret++;
		node = node.previousSibling;
	}
	return ret;
}
1268525
function getNodesByTypeHelper(childArray, type) {
  let nodes = [].concat(childArray.filter(element => element.type === type));
  let otherNodes = [];
  childArray.forEach(node => {
    if (hasChildren(node)) {
      otherNodes = otherNodes.concat(getNodesByTypeHelper(node.children, type));
    }
  });
  return nodes.concat(otherNodes);
}
212832
protected <T> Optional<T> getUserData(Optional<? extends Node> node, Class<T> type) {
        if (node.isPresent()) {
            final Node n = node.get();
            return getValue(n, n::getUserData, type);
        }
        return Optional.empty();
    }
540294
public List<AstNode> getChildrenForType( AstNode astNode,
                                             String nodeType ) {
        CheckArg.isNotNull(astNode, "astNode");
        CheckArg.isNotNull(nodeType, "nodeType");

        List<AstNode> childrenOfType = new ArrayList<AstNode>();
        for (AstNode child : astNode.getChildren()) {
            if (hasMixinType(child, nodeType)) {
                childrenOfType.add(child);
            }
            List<AstNode> subChildrenOfType = getChildrenForType(child, nodeType);
            childrenOfType.addAll(subChildrenOfType);
        }

        return childrenOfType;
    }
1169290
function (el, type) {
		while (el && el.nodeName.toLowerCase() !== type.toLowerCase()) {
			el = el.parentNode;
		}
		return el;
	}
969060
private V findSmallest(Node node) {
        if (node == null) {
            return null;
        }

        while (node.left != null) {
            node = node.left;
        }

        return node.item;
    }
829720
public static Node getEnclosingType(Node n, final Token type) {
    return getEnclosingNode(
        n,
        new Predicate<Node>() {
          @Override
          public boolean apply(Node n) {
            return n.getToken() == type;
          }
        });
  }
393500
def _get_node_type(self):
        """"""

        if self.parent is None:
            return self.NODE_ROOT
        elif self.parent.node_type == self.NODE_ROOT:
            return self.NODE_CONTROLLER_ROOT
        elif b".slice" in self.name or b'.partition' in self.name:
            return self.NODE_SLICE
        elif b".scope" in self.name:
            return self.NODE_SCOPE
        else:
            return self.NODE_CGROUP
1000297
private Scope findScopeForType(TypeElement type) {
    Scope scope = peekScope();
    while (scope != null) {
      if (scope.kind != ScopeKind.METHOD && type.equals(scope.type)) {
        return scope;
      }
      scope = scope.outer;
    }
    return null;
  }
897748
function(type) {
			var result = this.spirit.element.parentNode;
			if (type) {
				var spirit = result.spirit;
				if (spirit && spirit instanceof type) {
					result = spirit;
				} else {
					result = null;
				}
			}
			return result;
		}
1202250
public function indexXDT( &$types, &$node, &$element )
	{
		$xbrldtAttributes = $node->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLDT ] );
		if ( property_exists( $xbrldtAttributes, 'typedDomainRef' ) )
		{
			$element['typedDomainRef'] = (string) $xbrldtAttributes->typedDomainRef;
		}

		if ( ! empty( $element['substitutionGroup'] ) )
		{
			$id = $element['id'];
			$name = $element['name'];

			if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xbrldtDimensionItem ) ) )
			{
				$this->elementDimensions[] = $name;
			}
			else if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xbrldtHypercubeItem ) ) )
			{
				$this->elementHypercubes[] = $name;
			}
			else if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xlArc ) ) )
			{
				$this->elementArcTypes[] = $name;
			}
			else if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xlExtended ) ) )
			{
				$this->elementLinkTypes[] = $name;
			}
			// else if ( $element['type'] == XBRL_Constants::$enumItemType || $element['type'] == XBRL_Constants::$enumSetItemType )
			else if ( $types->resolvesToBaseType( $element['type'], array( XBRL_Constants::$enumItemType, XBRL_Constants::$enumSetItemType ), false ) )
			{
				// Record that this element is an extensible enumeration concept
				$this->enumerations[  $id ] = $id;

				// Make sure there is a linkrole and domain attribute
				$enumAttributes = $node->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_ENUMERATIONS ] );

				if ( property_exists( $enumAttributes, 'domain' ) )
				{
					$element['enumDomain'] = (string)$enumAttributes['domain'];
				}
				else
				{
					if ( $this->isValidating() )
					{
						$this->log()->taxonomy_validation( "Extensible enumerations", "The extensible concept does not include a domain",
							array(
								'id' => $id,
								'name' => $name,
								'type' => $element['substitutionGroup'],
								'error' => 'enumte:MissingDomainError'
							)
						);
					}
				}

				if ( property_exists( $enumAttributes, 'linkrole' ) )
				{
					$element['enumLinkrole'] = (string)$enumAttributes['linkrole'];
				}
				else
				{
					if ( $this->isValidating() )
					{
						$this->log()->taxonomy_validation( "Extensible enumerations", "The extensible concept does not include a linkrole",
							array(
								'id' => $id,
								'name' => $name,
								'type' => $element['substitutionGroup'],
								'error' => 'enumte:MissingLinkRoleError'
							)
						);
					}
				}

				$element['enumHeadUsable'] = property_exists( $enumAttributes, 'headUsable' )
					? filter_var( $enumAttributes['headUsable'], FILTER_VALIDATE_BOOLEAN )
					: false;
			}
		}

	}
576544
public int getNodeIndex(final Node node) {
        for (int i = 0; i < nodeList.size(); i++) {
            if (nodeList.get(i).equals(node)) {
                return i;
            }
        }
        return -1;
    }
1004800
public static <T extends TreeNode<T>> T getRoot(T node) {
        if (node == null) return null;
        if (node.getParent() != null) return getRoot(node.getParent());
        return node;
    }