@Nullable
  private static Map<PsiTypeParameter, PsiTypeParameter> calculateReplacementMap(final PsiSubstitutor substitutor,
                                                                                 final PsiClass targetClass,
                                                                                 final PsiElement containingElement) {
    final HashMap<PsiTypeParameter, PsiTypeParameter> result = new HashMap<>();
    for (PsiTypeParameter classTypeParameter : PsiUtil.typeParametersIterable(targetClass)) {
      if (!(substitutor.substitute(classTypeParameter) instanceof PsiClassType classType)) return null;
      if (!(classType.resolve() instanceof PsiTypeParameter methodTypeParameter)) return null;
      if (methodTypeParameter.getOwner() != containingElement) return null;
      if (result.containsKey(methodTypeParameter)) return null;
      result.put(methodTypeParameter, classTypeParameter);
    }
    return result;
  }
@Nullable
  private static Map<PsiTypeParameter, PsiTypeParameter> calculateReplacementMap(final PsiSubstitutor substitutor,
                                                                                 final PsiClass targetClass,
                                                                                 final PsiElement containingElement)