boolean (final Object element, final VirtualFile vFile) { if (element instanceof PackageElement packageElement) { final Set<Boolean> find = new HashSet<>(); final ContentIterator contentIterator = fileOrDir -> { if (fileOrDir.getPath().equals(vFile.getPath())) { find.add(Boolean.TRUE); } return true; }; final PsiPackage aPackage = packageElement.getPackage(); final Project project = aPackage.getProject(); final GlobalSearchScope scope = packageElement.getModule() != null ? GlobalSearchScope.moduleScope(packageElement.getModule()) : GlobalSearchScope.projectScope(project); final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final PsiDirectory[] directories = aPackage.getDirectories(scope); for (PsiDirectory directory : directories) { projectFileIndex.iterateContentUnderDirectory(directory.getVirtualFile(), contentIterator); } return !find.isEmpty(); } return false; }