code: @SuppressWarnings("unchecked")
    protected <T extends Component> T findAncestor(Class<T> clazz) {
      Stack<? extends Component> componentStack = getComponentStack();
      for (int i = componentStack.size() - 2; i >= 0; i--) {
        Component component = componentStack.get(i);
        if (clazz.equals(component.getClass())) return (T) component;
      }
      return null;
    }
docs: Finds the nearest ancestor of this component stack.
  
  @param clazz
  the class to look for, or if assignable from.
  @return the component if found, <tt>null</tt> if not.