Rewrite recursive call to Translate to a flat loop with a std::deque stack.