private @NotNull Set<PsiPackage> getPackageHierarchy(@NotNull String packageName) {
    final Set<PsiPackage> result = new HashSet<>();
    PsiPackage psiPackage = findPackage(packageName);
    if (psiPackage != null) {
      result.add(psiPackage);
    }
    else {
      return result;
    }
    while (psiPackage.getParentPackage() != null && !psiPackage.getParentPackage().getQualifiedName().isEmpty()) {
      final PsiPackage aPackage = findPackage(psiPackage.getParentPackage().getQualifiedName());
      if (aPackage == null) {
        break;
      }
      result.add(aPackage);
      psiPackage = psiPackage.getParentPackage();
    }
    return result;
  }
private @NotNull Set<PsiPackage> getPackageHierarchy(@NotNull String packageName)