boolean (@NotNull File root, @NotNull Processor<? super File> processor, @Nullable Processor<? super File> directoryFilter) { LinkedList<File> queue = new LinkedList<>(); queue.add(root); while (!queue.isEmpty()) { File file = queue.removeFirst(); if (!processor.process(file)) return false; if (directoryFilter != null && (!file.isDirectory() || !directoryFilter.process(file))) continue; File[] children = file.listFiles(); if (children != null) { ContainerUtil.addAll(queue, children); } } return true; }