Better avoid recursion and use a while loop instead.