Examines the given element and all its parent elements in order to find the "a" element.
@param e the child element to start with
@return the "a" element found or null if it is not present
185139
public static org.w3c.dom.Element findAnchorElement(org.w3c.dom.Element e)
    {
        if ("a".equalsIgnoreCase(e.getTagName().trim()))
            return e;
        else if (e.getParentNode() != null && e.getParentNode().getNodeType() == Node.ELEMENT_NODE)
            return findAnchorElement((org.w3c.dom.Element) e.getParentNode());
        else
            return null;
    }
956075
private boolean add_i(final GroupElement e) {
	if (e == null || e == this) {
	    // -DEBUG
	    System.out.println("Group::add_i::failed to add " + e.get_name() + " (null or self)");
	    return false;
	}
	final GroupElement ge = find_i(e.get_name(), e instanceof Group ? false : true);
	if (ge != null && ge != this) {
	    // -DEBUG
	    System.out.println("Group::add_i::failed to add " + e.get_name() + " (already attached)");
	    return false;
	}
	elements.add(e);
	e.set_parent(this);
	return true;
    }
1137121
@Nonnull
  @MustNotContainNull
  public static List<Element> findDirectChildrenForName(@Nonnull final Element element, @Nonnull final String childElementname) {
    final List<Element> resultList = new ArrayList<Element>();
    final NodeList list = element.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
      final Node node = list.item(i);
      if (element.equals(node.getParentNode()) && node instanceof Element && childElementname.equals(node.getNodeName())) {
        resultList.add((Element) node);
      }
    }
    return resultList;
  }
701874
public Element<T> find( T object ) {
		Element<T> e = first;
		while( e != null ) {
			if( e.object == object ) {
				return e;
			}
			e = e.next;
		}
		return null;
	}
607791
boolean contains(Linked<?> e) {
        return (e.getPrevious() != null)
                || (e.getNext() != null)
                || (e == first);
    }
1362513
public static Node findElementByName(String elementName, Node node)
	{

		if (
			node == null ||
			node.getNodeType() == Node.COMMENT_NODE ||
			node.getNodeType() == Node.TEXT_NODE
		)
			return null;

		if (elementName.equals(node.getNodeName()))
		{
			return node;
		}

		NodeList nodeList = node.getChildNodes();

		if (nodeList == null)
			return null;

		int len = nodeList.getLength();

		Node child;

		for (int i = 0; i < len; i++)
		{
			child = nodeList.item(i);

			if (child.getNodeType() == Node.TEXT_NODE)
				continue;

			if (elementName.equals(child.getNodeName()))
				return child;

			// check for next
			NodeList grands = child.getChildNodes();
			if (grands != null)
			{
				int grandsCnt = grands.getLength();
				for (int x = 0; x < grandsCnt; x++)
				{
					Node grandResults = findElementByName(elementName, grands.item(x));

					if (grandResults != null)
						return grandResults;
				}
			}
		}

		return null;
	}
34641
@SuppressWarnings("unchecked")
    public <T extends ElementBase> T findChildElement(Class<T> clazz) {
        for (ElementBase child : getChildren()) {
            if (clazz.isInstance(child)) {
                return (T) child;
            }
        }
        
        for (ElementBase child : getChildren()) {
            T child2 = child.findChildElement(clazz);
            
            if (child2 != null) {
                return child2;
            }
        }
        
        return null;
    }
575681
public HtmlElement findHtmlElementById(String elementId) {
        try {
            return htmlPage.getHtmlElementById(elementId);
        } catch (ElementNotFoundException e) {
            return null;
        }
    }
98535
static boolean isElementParentName(Element element, String name) {
        Element parent = element.getParentElement();
        if (parent == null) {
            return false;
        }
        return isElementName(parent, name);
    }
131159
protected Element getElement(Object parent, String name) {
		if (name == null) {
			return null;
		}
		String id;
		if (parent == null) {
			id = getRootElement().getId();
		} else {
			id = groupToId.get(parent);
		}
		return Dom.getElementById(Dom.assembleId(id, name));
	}
960564
protected XmlElement findMatchedElementIn(Document document, org.dom4j.Element element) {
    org.dom4j.Attribute id = element.attribute("id");
    String idName = id.getName();
    String idValue = id.getValue();
    for (Element me : document.getRootElement().getElements()) {
      if (me instanceof XmlElement) {
        XmlElement xe = (XmlElement) me;
        for (Attribute ab : xe.getAttributes()) {
          if (StringUtils.equals(idName, ab.getName()) && StringUtils.equals(idValue, ab.getValue())) {
            return xe;
          }
        }
      }
    }
    return null;
  }
249236
private static int getCharCount(Element e, String s) {
        if (s == null || s.length() == 0) {
            s = ",";
        }
        return getInnerText(e, true).split(s).length;
    }
432412
public static Element getElementNode(final Element element, final DitaClass classValue) {
        final NodeList list = element.getChildNodes();
        for (int i = 0; i < list.getLength(); i++) {
            final Node node = list.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                final Element child = (Element) node;
                if (classValue.matches(child)) {
                    return child;
                }
            }
        }
        return null;
    }
598242
function(element) {
		//We reached the top, no link found.
		if(element === document || !element) {
			return false;
		}

		//Yay, it's a link!
		if(element.tagName.toUpperCase() === 'A') {
			return element;
		}

		//Maybe the parent is a link.
		return findParentLink(element.parentNode);
	}
1360903
protected WebElement findElement(String by, String using, OperaWebElement el) {
    checkNotNull(using, "Cannot find elements when the selector is null");
    assertConnected();

    using = OperaStrings.escapeJsString(using);
    boolean isAvailable;
    Integer id;
    String script;

    if (el == null) {
      // Search the document
      script =
          "return " + OperaAtom.FIND_ELEMENT + "({\"" + by + "\": \"" + using + "\"})";
    } else {
      // Search within an element
      script =
          "return " + OperaAtom.FIND_ELEMENT + "({\"" + by + "\": \"" + using
          + "\"}, locator)";
    }

    if (el == null) {
      id = debugger.getObject(script);
    } else {
      id = debugger.executeScriptOnObject(script, el.getObjectId());
    }

    isAvailable = (id != null);

    if (isAvailable) {
      String error =
          debugger.callFunctionOnObject("return (locator instanceof Error) ? locator.message : ''",
                                        id);
      if (!error.isEmpty()) {
        throw new InvalidSelectorException(error);
      }

      Boolean isStale =
          Boolean.valueOf(debugger.callFunctionOnObject("locator.parentNode == undefined", id));

      if (isStale) {
        throw new StaleElementReferenceException("This element is no longer part of DOM");
      }

      return new OperaWebElement(this, id);
    } else {
      throw new NoSuchElementException("Cannot find element(s) with " + by);
    }
  }
1374470
public WebElement find() {
		checkState(webDriver != null, "No WebDriver specified.");
		checkState(by != null, "No By instance for locating elements specified.");

		if (!noLogging) {
			log.info(toString());
		}

		WebElement element;

		if (timeoutSeconds > 0L) {
			WebDriverWait wait = createWebDriverWait();
			element = wait.until(new Function<WebDriver, WebElement>() {
				@Override
				public WebElement apply(final WebDriver input) {
					WebElement el = input.findElement(by);
					checkElement(el);
					if (condition != null && !condition.apply(el)) {
						throw new WebElementException(String.format("Condition not met for element %s: %s", el, condition));
					}
					return el;
				}

				@Override
				public String toString() {
					return WebElementFinder.this.toString();
				}
			});
		} else {
			element = webDriver.findElement(by);
			checkElement(element);
			if (condition != null && !condition.apply(element)) {
				throw new WebElementException(String.format("Condition not met for element %s: %s", element, condition));
			}
		}

		return element;
	}
912205
def _element_get_or_add_from_parent(
        parent,  # type: ET.Element
        element_path  # type: Text
):
    # type: (...) -> ET.Element
    
    element_names = element_path.split('/')

    # Starting from the parent, walk the element path until we find the first element in the path
    # that does not exist. Create that element and all the elements following it in the path. If
    # all elements along the path exist, then we will simply walk the full path to the final
    # element we want to return.
    existing_element = None
    previous_element = parent
    for i, element_name in enumerate(element_names):
        existing_element = previous_element.find(element_name)
        if existing_element is None:
            existing_element = _element_append_path(previous_element, element_names[i:])
            break

        previous_element = existing_element

    assert existing_element is not None
    return existing_element