If your recursive method always calls itself, then you are going to have an infinite loop. In this case it's the stack overflow error which tells you that's happening. So your recursive method shouldn't always call itself. In other words there should be some condition under which the recursive call doesn't take place.
So in your code it's lines 35 and 36 which are recursively called unconditionally. You need to find some condition under which they don't need to be called.