@Override
  public PsiElement substituteElementToRename(@NotNull PsiElement element, @Nullable Editor editor) {
    final TypeEvalContext context = TypeEvalContext.codeInsightFallback(element.getProject());
    final PyFunction function = ObjectUtils.notNull(PyiUtil.getImplementation((PyFunction)element, context), (PyFunction)element);

    final PyClass containingClass = function.getContainingClass();
    if (containingClass == null) {
      return function;
    }
    if (PyUtil.isInitMethod(function)) {
      return containingClass;
    }

    final PyFunction deepestSuperMethod = PySuperMethodsSearch.findDeepestSuperMethod(function);
    if (!deepestSuperMethod.equals(function)) {
      final String message = PyBundle.message("python.rename.processor.override.message",
                                              function.getName(),
                                              containingClass.getQualifiedName(),
                                              deepestSuperMethod.getContainingClass().getQualifiedName());
      final int rc =
        Messages.showYesNoCancelDialog(element.getProject(), message, PyBundle.message("refactoring.rename"), Messages.getQuestionIcon());
      return switch (rc) {
        case Messages.YES -> deepestSuperMethod;
        case Messages.NO -> function;
        default -> null;
      };
    }

    final Property property = containingClass.findPropertyByCallable(function);
    if (property != null) {
      final PyTargetExpression site = property.getDefinitionSite();
      if (site != null) {
        if (ApplicationManager.getApplication().isUnitTestMode()) {
          return site;
        }
        final int rc =
          Messages.showYesNoCancelDialog(element.getProject(),
                                         PyBundle.message("python.rename.processor.property", property.getName(), function.getName()), PyBundle.message("refactoring.rename"), Messages.getQuestionIcon());
        return switch (rc) {
          case Messages.YES -> site;
          case Messages.NO -> function;
          default -> null;
        };
      }
    }

    return function;
  }
@Override
  public PsiElement substituteElementToRename(@NotNull PsiElement element, @Nullable Editor editor)