boolean (@NotNull PackageElement element, @NotNull VirtualFile file) { PsiPackage parent = getParentPackage(); for (PsiPackage p = element.getPackage(); p != null && !p.equals(parent); p = p.getParentPackage()) { for (PsiDirectory directory : p.getDirectories()) { if (directory.getVirtualFile().equals(file)) return true; } } return false; }