@NotNull
  public static PsiType nearestAccessibleType(@NotNull PsiType type) {
    while (!isAccessibleType(type)) {
      PsiClass psiClass = PsiTypesUtil.getPsiClass(type);
      boolean isAccessible = isAccessible(psiClass);
      if (isAccessible && hasInaccessibleGenerics(type)) {
        return TypeConversionUtil.erasure(type);
      }

      type = type.getSuperTypes()[0];
    }

    return type;
  }
@NotNull
  public static PsiType nearestAccessibleType(@NotNull PsiType type)