private static PsiClassType typeParameterErasureInner(@NotNull PsiTypeParameter typeParameter,
                                                        @NotNull Set<? super PsiClass> visited,
                                                        @NotNull PsiSubstitutor beforeSubstitutor) {
    final PsiClassType[] extendsList = typeParameter.getExtendsList().getReferencedTypes();
    if (extendsList.length > 0) {
      final PsiClass psiClass = extendsList[0].resolve();
      if (psiClass instanceof PsiTypeParameter) {
        if (!visited.contains(psiClass)) {
          visited.add(psiClass);
          if (beforeSubstitutor.getSubstitutionMap().containsKey(psiClass)) {
            return (PsiClassType)erasure(beforeSubstitutor.substitute((PsiTypeParameter)psiClass));
          }
          return typeParameterErasureInner((PsiTypeParameter)psiClass, visited, beforeSubstitutor);
        }
      }
      else if (psiClass != null) {
        return JavaPsiFacade.getElementFactory(typeParameter.getProject()).createType(psiClass);
      }
    }
    return PsiType.getJavaLangObject(typeParameter.getManager(), typeParameter.getResolveScope());
  }
private static PsiClassType typeParameterErasureInner(@NotNull PsiTypeParameter typeParameter,
                                                        @NotNull Set<? super PsiClass> visited,
                                                        @NotNull PsiSubstitutor beforeSubstitutor)