@NotNull
  private static String selectUniqueName(@NotNull String templateName, boolean templateIsType, @NotNull PsiElement scopeAnchor, @NotNull BiPredicate<String, PsiElement> isValid) {
    final Collection<String> suggestions;
    if (templateIsType) {
      suggestions = NameSuggesterUtil.generateNamesByType(templateName);
    }
    else {
      suggestions = NameSuggesterUtil.generateNames(templateName);
    }
    for (String name : suggestions) {
      if (isValid.test(name, scopeAnchor)) {
        return name;
      }
    }

    final String shortestName = ContainerUtil.getFirstItem(suggestions);
    return appendNumberUntilValid(shortestName, scopeAnchor, isValid);
  }
@NotNull
  private static String selectUniqueName(@NotNull String templateName, boolean templateIsType, @NotNull PsiElement scopeAnchor, @NotNull BiPredicate<String, PsiElement> isValid)