code: 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;
      }
docs: 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