public static @NotNull <T> List<T> collectExpandedObjects(@NotNull JTree tree, @NotNull Function<? super TreePath, ? extends T> mapper) {
    int count = tree.getRowCount();
    if (count == 0) return Collections.emptyList(); // tree is empty
    List<T> list = new ArrayList<>();
    for (int row = 0; row < count; row++) {
      if (tree.isExpanded(row)) {
        TreePath path = getVisiblePathWithValidation(tree, row, count);
        ContainerUtil.addIfNotNull(list, mapper.apply(path));
      }
    }
    return list;
  }
public static @NotNull <T> List<T> collectExpandedObjects(@NotNull JTree tree, @NotNull Function<? super TreePath, ? extends T> mapper)