Write while loop equivalent in elixir

Well if you want to limit the depth, you can always pass along a depth counter. But you probably won’t want to limit depth–other than to make sure that the recursive call is the last thing your function does, so that tail call optimization can limit the actual stack depth to 1.