@Coorae: I use an array, and store how deep the recursion goes. Now, whenever the recursion gets too deep, store the location that would have been next in the array, and dont fill it.
Now, at the end of the function when recursions=1, Go through and call the function once at each of these points. :)
Now, at the end of the function when recursions=1, Go through and call the function once at each of these points. :)