A recursive solution that works on every sample and dies on the large test is one of the most common failure modes in the trees and graphs tracks. The tree is a degenerate left spine of 10^5 nodes, the recursion goes 10^5 frames deep, and the runtime gives up.
Why raising the limit is not the fix
In CPython, sys.setrecursionlimit raises the interpreter's own counter but does nothing about the actual C stack underneath it. Raise it far enough and the program stops raising a clean RecursionError and starts segfaulting instead — you have traded a catchable error for a crash. It is a workaround with a cliff in it.
sys.setrecursionlimit(300000) is the algorithmic equivalent of taping over a warning light.
Pre-order converts trivially
If all the work happens on the way down, the conversion is mechanical: push the root, pop, process, push children. Push the right child first so the left is processed first.
Post-order is where people slip
Post-order needs each node visited twice: once to schedule its children, once to combine their results. The clean way to express that is to push a marker alongside the node saying which visit this is.
That two-state marker is exactly the return address a real stack frame carries. You are not inventing a trick; you are writing down by hand what the language was doing for you.
Carrying return values
When the recursion returns a value rather than appending to a list, keep a dictionary from node to computed result, filled in on the combine visit. The parent reads its children out of that dictionary because, by the time a parent is expanded, both children have already been written.
When not to bother
If the depth is provably logarithmic — a balanced tree, a divide-and-conquer split — recursion is fine and clearer. Convert when the depth can be linear in the input: linked lists, unbalanced trees, path-shaped graphs, and any DFS on a general graph where the input could be a long chain.
Reading about a pattern is not the same as producing it under time pressure. The problems that drill this are in the curriculum, in order.