Are there any general rules when using recursion on how to avoid stackoverflows?
Other than having a reasonable stack size and making sure you divide and conquer your problem such that you continually work on a smaller problem, not really.