/* Finds the first element of the given tag type within a parent element.
Used for finding the first LI[ST] within a L[IST]I[TEM].
328990
function (element, containerTag) {
    if (element && element.hasChildNodes)
      for (var i = 0; i < element.childNodes.length; ++i)
        if (element.childNodes[i].tagName == containerTag)
          return element.childNodes[i];
  
    return null;
  }
741042
static public Element selectParentElement(Element element, String parentName) {
		Element parentElement = (Element) element.getParentNode();
		if (parentElement == null) {
			return null;
		}
		if (parentElement.getTagName().equals(parentName)) {
			return parentElement;
		}
		return selectParentElement(parentElement, parentName);
	}
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;
		}
822046
function findFirstSubNodeLTR (node, type) {
  if (!node || !node.children) return null
  for (let i = 0; i < node.children.length; ++i) {
    var item = node.children[i]
    if (nodeType(item, type)) return item
    else {
      var res = findFirstSubNodeLTR(item, type)
      if (res) return res
    }
  }
  return null
}
489047
public int findElement(Object bookmark, int iHandleType)
    {
        if (bookmark == null)
            return -1;
        int iTargetPosition = m_gridBuffer.findElement(bookmark, iHandleType);
        if (iTargetPosition == -1)
            iTargetPosition = m_gridList.findElement(bookmark, iHandleType);
        return iTargetPosition;   // Not found
    }
1173771
function findClosestParent(startElement, fn) {
            var parent = startElement.parentElement;
            if (!parent) {
                return undefined;
            }
            return fn(parent) ? parent : findClosestParent(parent, fn);
        }
1244740
def getElementsByTagName(start_node: ParentNode, tag: str) -> NodeList:
    """"""
    _tag = tag.upper()
    return getElementsBy(start_node, lambda node: node.tagName == _tag)
1116889
function matchSelector(element, selector) {
        if (!element || element.nodeType !== 1) {
            return false
        }

        var parent,
            match,
            matchesSelector = element.webkitMatchesSelector || element.matchesSelector;

        if (matchesSelector) {
            match = matchesSelector.call(element, selector)
        } else {
            parent = element.parentNode;
            match = !! parent.querySelector(selector);
        }

        return match;
    }
31480
function getMarker(node, markerType, parentNode) {
  var id = referenceToId(svgAttr(node, markerType));

  return domQuery('marker#' + id, parentNode || document);
}
644115
public boolean nextInnerElement(ElementContext parent) throws XMLException, IOException {
		if (event.context.isEmpty()) return false;
		if (Type.START_ELEMENT.equals(event.type) && event.context.getFirst() == parent && event.isClosed)
			return false; // we are one the opening tag of the parent, and it is closed, so it has no content
		if (Type.END_ELEMENT.equals(event.type) && event.context.getFirst() == parent)
			return false;
		try {
			do {
				next();
				if (Type.END_ELEMENT.equals(event.type)) {
					if (event.context.getFirst() == parent)
						return false;
				}
				if (Type.START_ELEMENT.equals(event.type)) {
					if (event.context.size() > 1 && event.context.get(1) == parent)
						return true;
				}
			} while (true);
		} catch (EOFException e) {
			return false;
		}
	}
154045
function getIndexOfType(element) {
  let index = 0;
  let child;
  while ((child = element.previousElementSibling)) {
    if (child.tagName === element.tagName) {
      index++;
    }
  }
  return index;
}
205505
function getNearestTypeElement(element) {
		var $element = $(element),
			found = $element.is('[data-type]');

		while (!found && $element.length && !$element.is(MODULE_SELECTOR)) {
			$element = $element.parent();
			found = $element.is('[data-type]');
		}

		return found ? $element[0] : null;
	}
23236
function getParentSelector() {
  const type = NodeType.ParentSelectorType;
  const token = tokens[pos];
  const line = token.ln;
  const column = token.col;
  const content = '&';

  pos++;

  return newNode(type, content, line, column);
}
960802
public List<Element> findElements(Class<?> type) {
    List<Element> result = new ArrayList<>();
    LinkedList<Element> stack = new LinkedList<>(this.getChildren());

    if (this.getClass() == type) {
      result.add(this);
    }

    while (!stack.isEmpty()) {
      Element child = stack.pop();
      stack.addAll(0, child.getChildren());
      if (child.getClass() == type) {
        result.add(child);
      }
    }

    return result;
  }
1239297
function getImmediateCustomParentTag(tag) {
  var ptag = tag;
  while (ptag.__.isAnonymous) {
    if (!ptag.parent) { break }
    ptag = ptag.parent;
  }
  return ptag
}
877494
function( elem ) {
		if ( !elem || typeof elem === "string" ) {
			return jQuery.inArray( this[0],
				// If it receives a string, the selector is used
				// If it receives nothing, the siblings are used
				elem ? jQuery( elem ) : this.parent().children() );
		}
		// Locate the position of the desired element
		return jQuery.inArray(
			// If it receives a jQuery object, the first element is used
			elem.jquery ? elem[0] : elem, this );
	}
82219
public List<Element> findElements(String tag) {
    List<Element> result = new ArrayList<>();
    LinkedList<Element> stack = new LinkedList<>(this.getChildren());

    if (tag.equalsIgnoreCase(this.getMessageMLTag())) {
      result.add(this);
    }

    while (!stack.isEmpty()) {
      Element child = stack.pop();
      stack.addAll(0, child.getChildren());
      if (tag.equalsIgnoreCase(child.getMessageMLTag())) {
        result.add(child);
      }
    }

    return result;
  }