So you have to reevalute the logic, see if it possible that the recusion could cause extremely many nested calls, or if the logic is wrong and not stopping the recursive calls. Usually this happens when logic is wrong causing inifinite recursive calls.
You're asking us to help fix code that we've never seen. That means that we can only provide very general advice and that should be stuff that you have already considered yourself. If your code doesn't work then your code is probably wrong. If we can't see your code, we can't see what's wrong with it.
That said, don't just post code and that's it. Provide a FULL and CLEAR explanation, which includes the logic that the code is supposed to implement. If you say that you want to do X and we see that the code does Y then the issue is obvious. If you just show code that does Y then we'll assume that you want to do Y.