private static <T extends DomElement> T _getParentOfType(Class<T> requiredClass, DomElement element) {
    while (element != null && !requiredClass.isInstance(element)) {
      element = element.getParent();
    }
    return (T)element;
  }
private static <T extends DomElement> T _getParentOfType(Class<T> requiredClass, DomElement element)