PsiPackage (@NotNull PsiPackage rootPackage, Module module, Project project, TodoTreeBuilder builder, GlobalSearchScope scope) { if (!isPackageEmpty(new PackageElement(module, rootPackage, false), builder, project)){ return rootPackage; } final PsiPackage[] subPackages = rootPackage.getSubPackages(scope); PsiPackage suggestedNonEmptyPackage = null; int count = 0; for (PsiPackage aPackage : subPackages) { if (!isPackageEmpty(new PackageElement(module, aPackage, false), builder, project)){ if (++ count > 1) return rootPackage; suggestedNonEmptyPackage = aPackage; } } for (PsiPackage aPackage : subPackages) { if (aPackage != suggestedNonEmptyPackage) { PsiPackage subPackage = findNonEmptyPackage(aPackage, module, project, builder, scope); if (subPackage != null){ if (count > 0){ return rootPackage; } else { count ++; suggestedNonEmptyPackage = subPackage; } } } } return suggestedNonEmptyPackage; }