code: public static Element getAncestor(Element element, String className) {
  
          if (hasClass(className, element)) {
              return element;
          }
          if (element.getTagName().equalsIgnoreCase(Tag.body.name())) {
              return null;
          }
          return getAncestor(element.getParentElement(), className);
      }
docs: Returns the given element or it's closest ancestor with the given class.<p>
  
  Returns <code>null</code> if no appropriate element was found.<p>
  
  @param element the element
  @param className the class name
  
  @return the matching element