private static @NotNull String suggestClassName(@NotNull PsiElement place, @NotNull String name) {
    PsiResolveHelper helper = PsiResolveHelper.getInstance(place.getProject());
    return UniqueNameGenerator.generateUniqueNameOneBased(
      name,
      n -> helper.resolveReferencedClass(n, place) == null &&
           !(place instanceof PsiClass && place.getParent() instanceof PsiDeclarationStatement decl &&
             decl.getParent() instanceof PsiCodeBlock block &&
             SyntaxTraverser.psiTraverser(block).filter(PsiClass.class).find(cls -> n.equals(cls.getName())) != null));
  }
private static @NotNull String suggestClassName(@NotNull PsiElement place, @NotNull String name)