Search each parent of some verb for a given element.
 Used for rule inheritance.
500607
def search_current_el xpath
      # try to find the rule in the current verb
      desired_el = @current_el.at_xpath xpath
      return desired_el unless desired_el.nil?
      
      # check all the verb's parents, walking up the hierarchy
      @current_el_parents.each do |parent|
        desired_el = parent.at_xpath xpath
        return desired_el unless desired_el.nil?
      end
      
      nil
    end
223988
def find_lemma(self, verb):
        
        v = verb.lower()
        # Common prefixes: be-finden and emp-finden probably inflect like finden.
        if not (v.startswith("ge") and v.endswith("t")): # Probably gerund.
            for prefix in prefixes:
                if v.startswith(prefix) and v[len(prefix):] in self.inflections:
                    return prefix + self.inflections[v[len(prefix):]]
        # Common sufixes: setze nieder => niedersetzen.
        b, suffix = " " in v and v.split()[:2] or  (v, "")
        # Infinitive -ln: trommeln.
        if b.endswith(("ln", "rn")):
            return b
        # Lemmatize regular inflections.
        for x in ("test", "est", "end", "ten", "tet", "en", "et", "te", "st", "e", "t"):
            if b.endswith(x): b = b[:-len(x)]; break
        # Subjunctive: hielte => halten, schnitte => schneiden.
        for x, y in (
          ("ieb",  "eib"), ( "ied", "eid"), ( "ief",  "auf" ), ( "ieg", "eig" ), ("iel", "alt"), 
          ("ien",  "ein"), ("iess", "ass"), (u"ieß", u"aß"  ), ( "iff", "eif" ), ("iss", "eiss"), 
          (u"iß", u"eiß"), (  "it", "eid"), ( "oss",  "iess"), (u"öss", "iess")):
            if b.endswith(x): b = b[:-len(x)] + y; break
        b = b.replace("eeiss", "eiss")
        b = b.replace("eeid", "eit")
        # Subjunctive: wechselte => wechseln
        if not b.endswith(("e", "l")) and not (b.endswith("er") and len(b) >= 3 and not b[-3] in VOWELS):
            b = b + "e"
        # abknallst != abknalln => abknallen
        if b.endswith(("hl", "ll", "ul", "eil")):
            b = b + "e"
        # Strip ge- from (likely) gerund:
        if b.startswith("ge") and v.endswith("t"):
            b = b[2:]
        # Corrections (these add about 1.5% accuracy):
        if b.endswith(("lnde", "rnde")):
            b = b[:-3]
        if b.endswith(("ae", "al", u"öe", u"üe")):
            b = b.rstrip("e") + "te"
        if b.endswith(u"äl"):
            b = b + "e"
        return suffix + b + "n"
285112
function search(keyword, typeFilter) {
        keyword = keyword.toLowerCase();
        typeFilter = typeFilter || type.Element;
        var results = findAll(function (elem) {
            var name = elem.name ? elem.name.toLowerCase() : "";
            return (name.indexOf(keyword) > -1 && elem instanceof typeFilter);
        });
        return results;
    }
734285
function closest (el, sel) {
  if (!el) return
  if (matches(el, sel)) {
    return el
  } else {
    return closest(el.parentNode, sel)
  }
}
1224201
function (el, e) {

		var related = e.relatedTarget;

		if (!related) { return true; }

		try {
			while (related && (related !== el)) {
				related = related.parentNode;
			}
		} catch (err) {
			return false;
		}
		return (related !== el);
	}
11898
function ( obj, arg ) {
		if ( regex.selector_is.test( arg ) ) {
			utility.id( obj );
			return ( element.find( obj.parentNode, obj.nodeName.toLowerCase() + arg ).filter( function ( i ) {
				return ( i.id === obj.id );
			}).length === 1 );
		}
		else {
			return new RegExp( arg, "i" ).test( obj.nodeName );
		}
	}
675407
function ancestorMatch(el, tokens, dividedTokens, root) {
      var cand
      // recursively work backwards through the tokens and up the dom, covering all options
      function crawl(e, i, p) {
        while (p = walker[dividedTokens[i]](p, e)) {
          if (isNode(p) && (found = interpret.apply(p, q(tokens[i])))) {
            if (i) {
              if (cand = crawl(p, i - 1, p)) return cand
            } else return p
          }
        }
      }
      return (cand = crawl(el, tokens.length - 1, el)) && (!root || isAncestor(cand, root))
    }
896684
def findTypeParent(element, tag):
    

    p = element
    while True:
        p = p.getparent()
        if p.tag == tag:
            return p

    # Not found
    return None
1173771
function findClosestParent(startElement, fn) {
            var parent = startElement.parentElement;
            if (!parent) {
                return undefined;
            }
            return fn(parent) ? parent : findClosestParent(parent, fn);
        }
334763
def get_element_attributes(parent_to_parse, element_path=None):
    

    element = get_element(parent_to_parse, element_path)

    return {} if element is None else element.attrib
1010838
function findPrev(type/*: string*/, element/*: Cheerio*/) {
  let tries = 5
  let prev = element

  do {
    if (prev.is(type)) {
      return prev
    }

    prev = prev.prev()
  }
  while (--tries)

  return prev
}
901616
def has_parent(self, term):
        """"""
        for parent in self.parents:
            if parent.item_id == term or parent.has_parent(term):
                return True
        return False
1047377
def get(cls, parent, name):
        """"""
        return cls.query.filter_by(parent=parent, name=name).one_or_none()
1043750
def getchild(self, name, parent):
        
        #log.debug('searching parent (%s) for (%s)', Repr(parent), name)
        if name.startswith('@'):
            return parent.get_attribute(name[1:])
        else:
            return parent.get_child(name)
930019
function _getElements(parent, list, criteria){
    var childNodes = parent.childNodes;
    if (!childNodes) return list;
    for (var node, i = 0, n = childNodes.length; i < n; i++){
        node = childNodes[i];
        if (criteria && criteria.call(null, node) === true) list.push(node);
        _getElements(node, list, criteria);
    }
}
161130
function (scope, selector, isRoot) {
      // It may surprise you to learn this is exactly what JQuery does
      // TODO: Avoid all this wrapping and unwrapping
      return PredicateFilter.ancestors(scope, function (e) {
        return Selectors.is(e, selector);
      }, isRoot);
    }
292044
def FindParentMember(cls, typecheck_parent, name):
    """"""
    if typecheck_parent and hasattr(typecheck_parent, name):
      return getattr(typecheck_parent, name)
    return None