What is the memory complexity of the following function?

```
def remove_nodes_with_value_recursive(head,x):
if not head:
return
head.next = remove_nodes_with_value_recursive(head.next, x)
return head.next if head.val is x else head
```

My guess is O(n) because N recursive calls are made, so it adds those parameters N times to the stack. Is that correct? If not, please explain why.

pythonalgorithmrecursionlinked-listbig-o