Find the first :class:`Element` node descendant of this node that
        matches any optional constraints, or None if there are no matching
        elements.

        Delegates to :meth:`find` with ``first_only=True``.
512394
def find_first(self, name=None, ns_uri=None):
        
        return self.find(name=name, ns_uri=ns_uri, first_only=True)
397441
def _find_by_nsp(self, browser, criteria, tag, constraints):
        """"""
        return self._filter_elements(
            browser.find_elements_by_ios_predicate(criteria),
            tag, constraints)
348237
def search(cls, element, pattern):
        
        if isinstance(element, Layout):
            return [el for cell in element for el in cls.search(cell, pattern)]
        if isinstance(element, (NdOverlay, Overlay)):
            return [el for el in element if el.matches(pattern)]
        elif isinstance(element, Element):
            return [element] if element.matches(pattern) else []
544769
public static <E> Optional<E> find(final Iterable<E> iterable, final Predicate<E> pred) {
        for (E element : iterable) {
            if (pred.test(element)) {
                return Optional.of(element);
            }
        }
        return Optional.absent();
    }
1363120
def is_descendant_of(self, node):
        
        return self.path.startswith(node.path) and self.depth > node.depth
1147146
public void hasFirstElement(@NullableDecl Object element) {
    if (actualAsNavigableSet().isEmpty()) {
      failWithActual("expected to have first element", element);
      return;
    }

    if (!Objects.equal(actualAsNavigableSet().first(), element)) {
      if (actualAsNavigableSet().contains(element)) {
        failWithoutActual(
            simpleFact(
                lenientFormat(
                    "Not true that %s has first element <%s>. "
                        + "It does contain this element, but the first element is <%s>",
                    actualAsString(), element, actualAsNavigableSet().first())));
        return;
      }
      failWithoutActual(
          simpleFact(
              lenientFormat(
                  "Not true that %s has first element <%s>. "
                      + "It does not contain this element, and the first element is <%s>",
                  actualAsString(), element, actualAsNavigableSet().first())));
    }
  }
633318
def match(node)
      raise_unless_xpath!(node)
      pos = node.xpath("descendant::pos").first
      return nil if pos.nil?
      { matched: node.respond_to?(:name) ? node.name : "",
        line: pos["line"].to_i, column: pos["column"].to_i }
    end
956746
public int find() {
        for (int node = root; node != NIL; ) {
            final int cmp = compare(node);
            if (cmp < 0) {
                node = left(node);
            } else if (cmp > 0) {
                node = right(node);
            } else {
                return node;
            }
        }
        return NIL;
    }
1300074
def _element_find_from_root(
        root,  # type: ET.Element
        element_path  # type: Text
):
    # type: (...) -> Optional[ET.Element]
    
    element = None

    element_names = element_path.split('/')
    if element_names[0] == root.tag:
        if len(element_names) > 1:
            element = root.find('/'.join(element_names[1:]))
        else:
            element = root

    return element
472946
def find_element(self, by, value, view_cls=None):
        # type: (By, Any, View) -> View
        
        if view_cls is None:
            view_cls = View

        return view_cls(lambda: self.root.find_element(by, value))
434698
def find_element(self, by, value, view_cls=None):
        # type: (By, Any, View) -> View
        
        if view_cls is None:
            view_cls = View

        return view_cls(lambda: self.driver.find_element(by, value))
771736
def precedes(self, other):
        """"""
        try:
            ancestor = next(commonancestors(AbstractElement, self, other))
        except StopIteration:
            raise Exception("Elements share no common ancestor")
        #now we just do a depth first search and see who comes first
        def callback(e):
            if e is self:
                return True
            elif e is other:
                return False
            return None
        result = ancestor.depthfirstsearch(callback)
        if result is None:
            raise Exception("Unable to find relation between elements! (shouldn't happen)")
        return result
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;
              }
            }
          }
        }
714074
def find_ele_by_predicate(class_name: '*', value:)
      elements = find_eles_by_predicate(class_name: class_name, value: value)
      raise _no_such_element if elements.empty?

      elements.first
    end
1001217
def get_first_of_element(element, sub, contype=None):
    
    content = element.xpath(sub)
    return list_or_empty(content, contype)
43649
function findAncestor(node, predicate) {
  var last = false;
  while (node != null && !(last = predicate(node))) {
    node = node.parentNode;
  }
  return last ? node : null;
}
1311440
function () {
            var elem = this[0];
            // No argument, return index in parent
            if (!elem) {
                return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
            }

            // Index in selector
            if (typeof elem === 'string') {
                return indexOf.call(vQ(elem), this[0]);
            }

            // Locate the position of the desired element
            return indexOf.call(this,

                // If it receives a vQ object, the first element is used
                elem.constructor == vQ ? elem[0] : elem
            );
        }