Microsoft Interview Question

How to refactor recursive calls to avoid possible stack overflow?