The simple answer is that recursion is the wrong tool to use for iterating over the contents of a list. That is an iterative sequential algorithm and recursion will fail when the list gets too big. It's not a question of adjusting the recursive algorithm, it's just wrong and will always fail for a large enough list, where simple iteration would continue to work just fine.
The specific reason recursion fails is that each recursive call consumes a stack frame's worth of memory, which includes some housekeeping information and instances of all local variables in the method. Eventually you run out of stack space, which results in a StackOverflow exception.
The recursive solution will always have an upper limit to the size of list it can handle which will almost surely be a lot smaller than the size of list you can store in memory. You can increase the limit by allocating more stack space (using the -Xss
command line option), but the limit is fundamentally part of the algorithm and the way recursion works in languages like Java.
If you are interested, look up the term "tail recursion". There are some languages where the compiler (or interpreter) will detect this and convert it to iteration (I think Lisp does this).