Module (@NotNull VirtualFile rootDir, @Nullable final Consumer<? super Module> moduleConsumer) { final Ref<Module> result = Ref.create(); VfsUtilCore.visitChildrenRecursively(rootDir, new VirtualFileVisitor<Void>() { @Override public boolean visitFile(@NotNull VirtualFile file) { if (!file.isDirectory() && file.getName().endsWith(ModuleFileType.DOT_DEFAULT_EXTENSION)) { Module module = loadModule(file); if (moduleConsumer != null) { moduleConsumer.consume(module); } result.setIfNull(module); } return true; } }); return result.get(); }