private static @Nullable PsiTypeParameter getReturnTypeParameterNotMentionedPreviously(int index, PsiMethod method) {
      PsiTypeParameter returnTypeParameter = ObjectUtils.tryCast(PsiUtil.resolveClassInClassTypeOnly(method.getReturnType()), PsiTypeParameter.class);
      if (returnTypeParameter == null || returnTypeParameter.getOwner() != method) return null;
      PsiParameter[] parameters = method.getParameterList().getParameters();
      for (int i = 0; i < index && i < parameters.length; i++) {
        PsiType prevParameterType = parameters[i].getType();
        if (PsiTypesUtil.mentionsTypeParameters(prevParameterType, Set.of(returnTypeParameter))) return null;
      }
      return returnTypeParameter;
    }
private static @Nullable PsiTypeParameter getReturnTypeParameterNotMentionedPreviously(int index, PsiMethod method)