JBIterable<TreePath> (JTree tree, boolean expand) { JBIterable<TreePath> paths; if (expand) { paths = TreeUtil.treePathTraverser(tree).traverse(); } else { TreePath[] arr = new TreePath[tree.getRowCount()]; for (int i = 0; i < arr.length; i++) { arr[i] = tree.getPathForRow(i); } paths = JBIterable.of(arr); } return paths.filter(o -> !(o.getLastPathComponent() instanceof LoadingNode)); }