private static @Nullable PsiTypeParameter getSoleTypeParameter(@Nullable PsiType type) {
    if (!(type instanceof PsiClassType)) return null;
    PsiType[] parameters = ((PsiClassType)type).getParameters();
    if (parameters.length != 1) return null;
    PsiType parameter = parameters[0];
    if (parameter instanceof PsiWildcardType) {
      parameter = ((PsiWildcardType)parameter).getExtendsBound();
    }
    if (!(parameter instanceof PsiClassType)) return null;
    return tryCast(((PsiClassType)parameter).resolve(), PsiTypeParameter.class);
  }
private static @Nullable PsiTypeParameter getSoleTypeParameter(@Nullable PsiType type)