private static <T extends JComponent> void findComponentsOfType(@Nullable JComponent parent,
                                                                  @NotNull Class<T> cls,
                                                                  @NotNull List<? super T> result) {
    if (parent == null) return;
    if (cls.isAssignableFrom(parent.getClass())) {
      @SuppressWarnings("unchecked") final T t = (T)parent;
      result.add(t);
    }
    for (Component c : parent.getComponents()) {
      if (c instanceof JComponent) {
        findComponentsOfType((JComponent)c, cls, result);
      }
    }
  }
private static <T extends JComponent> void findComponentsOfType(@Nullable JComponent parent,
                                                                  @NotNull Class<T> cls,
                                                                  @NotNull List<? super T> result)