This is going to depend on your data size: Python has a default recursion limit of 999 calls (although that can be changed with
Python | sys.setrecursionlimit() method - GeeksforGeeks[
^]) unless your test dtaa has 1000 items or more in it - and I doubt that for such early code - increasing the limit will only make you wait a little longer for the error to occur.
Recursion (as I'm sure you know) is when a function calls itself, either directly by using the function name inside the function, or indirectly by calling a function which calls the first function. Sometimes that is what you want, and the classic example is Factorial:
Factorial(n) == n * Factorial(n - 1)
Provided the Factorial function includes a check for "one or below" to terminate the recursion it works well. (An iterative solution is more efficient, but Factorial is often used to demonstrate the concept).
If you omit the termination check though, the Factorial function just continues to call itself until the machine executing it runs out of memory to store where it has to go back to, and the app crashes.
Python restricts that by having a very small limit on how "deep" recursion can go - 999 calls is the default.
Your app is exceeding that default, and unless you have more than 999 items in a single branch of your tree, that means your code is lacking the termination check, or your tree actually has a loop in it.
I'd suggest that you use the
debugger[
^] to follow exactly what is happening, and work out if it's a code or data problem.
Sorry, but we can't do that for you!