private static List<PyReferenceExpression> collectExpressionsToRename(@NotNull final PyReferenceExpression expression,
                                                                        @NotNull final ScopeOwner parentScope) {

    final List<PyReferenceExpression> result = new ArrayList<>();
    PyRecursiveElementVisitor visitor = new PyRecursiveElementVisitor() {
      @Override
      public void visitPyReferenceExpression(@NotNull PyReferenceExpression node) {
        if (node.textMatches(expression) && !isValidReference(node.getReference())) {
          result.add(node);
        }
        super.visitPyReferenceExpression(node);
      }
    };

    parentScope.accept(visitor);
    return result;
  }
private static List<PyReferenceExpression> collectExpressionsToRename(@NotNull final PyReferenceExpression expression,
                                                                        @NotNull final ScopeOwner parentScope)