Flatten recursive add into an explicit list-based stack