boolean (@NotNull JTree tree, @NotNull TreePath parent, @NotNull Predicate<? super TreePath> predicate) { boolean tested = false; for (int row = Math.max(0, 1 + tree.getRowForPath(parent)); row < tree.getRowCount(); row++) { TreePath path = tree.getPathForRow(row); if (!parent.isDescendant(path)) break; if (!predicate.test(path)) return false; tested = true; // at least one descendant tested } return tested; }