PsiElement (final PsiElement psiElement) { if (psiElement instanceof PsiPackage psiPackage) { final PsiPackage parentPackage = psiPackage.getParentPackage(); if (parentPackage != null && !parentPackage.getQualifiedName().isEmpty()) { return parentPackage; } } return super.getParent(psiElement); }