Microsoft interview question

How to refactor recursive calls to avoid possible stack overflow?