@NotNull
  private static List<PsiElement> collectScopes(@NotNull PsiElement anchor, @NotNull PyFunction generatedMethod) {
    final ScopeOwner owner = ScopeUtil.getScopeOwner(anchor);
    if (owner instanceof PsiFile) return Collections.emptyList();
    final List<PsiElement> scope = new ArrayList<>();
    if (owner instanceof PyFunction pyFunction) {
      scope.add(pyFunction.getStatementList());
      final PyClass containingClass = pyFunction.getContainingClass();
      if (containingClass != null) {
        for (PyFunction function : containingClass.getMethods()) {
          if (!function.equals(owner) && !function.equals(generatedMethod)) {
            scope.add(function.getStatementList());
          }
        }
      }
    }
    return scope;
  }
@NotNull
  private static List<PsiElement> collectScopes(@NotNull PsiElement anchor, @NotNull PyFunction generatedMethod)