Iterator<PsiFile> (PackageElement packageElement) { ArrayList<PsiFile> psiFileList = new ArrayList<>(); GlobalSearchScope scope = packageElement.getModule() != null ? GlobalSearchScope.moduleScope(packageElement.getModule()) : GlobalSearchScope.projectScope(myProject); final PsiDirectory[] directories = packageElement.getPackage().getDirectories(scope); for (PsiDirectory directory : directories) { Iterator<PsiFile> files = myBuilder.getFiles(directory, false); while (files.hasNext()) { psiFileList.add(files.next()); } } return psiFileList.iterator(); }