private static @Nullable String getPublicApiPackageName(@NotNull PsiClass psiClass) {
    if (psiClass.hasModifierProperty(PsiModifier.PUBLIC) || psiClass.hasModifierProperty(PsiModifier.PROTECTED)) {
      PsiElement parent = psiClass.getParent();
      if (parent instanceof PsiClass clazz) {
        return getPublicApiPackageName(clazz);
      }
      if (parent instanceof PsiJavaFile file) {
        return file.getPackageName();
      }
    }
    return null;
  }
private static @Nullable String getPublicApiPackageName(@NotNull PsiClass psiClass)