List<VirtualFile> (@NotNull VirtualFile dir, @NotNull VirtualFileFilter filter) { List<VirtualFile> result = null; for (VirtualFile child : dir.getChildren()) { if (filter.accept(child)) { if (result == null) result = new SmartList<>(); result.add(child); } } return result != null ? result : List.of(); }