boolean (final Object object, final Object rootElement, final Processor<Object> processor) { if (object instanceof Project) { return processChildren((Project)object, processor); } else if (object instanceof Module) { return processChildren((Module)object, processor); } else if (object instanceof PsiDirectoryContainer psiPackage) { final PsiDirectory[] psiDirectories = ReadAction.compute(() -> rootElement instanceof Module ? psiPackage.getDirectories( GlobalSearchScope.moduleScope((Module)rootElement)) : psiPackage.getDirectories()); for (PsiDirectory psiDirectory : psiDirectories) { if (!processChildren(psiDirectory, rootElement, processor)) return false; } return true; } else if (object instanceof PsiDirectory) { return processChildren((PsiDirectory)object, rootElement, processor); } else if (object instanceof PsiFileSystemItem) { return processChildren((PsiFileSystemItem)object, processor); } return true; }