void (NavigableSet<String> paths, String prefix, Collection<? super String> result) { var possibleRoot = paths.ceiling(prefix); if (possibleRoot != null && FileUtil.startsWith(possibleRoot, prefix)) { // It's worth going for the set and iterator for (var root : paths.tailSet(prefix, false)) { if (FileUtil.startsWith(root, prefix)) { result.add(root); } else { return; } } } }