Rewrite the binary tree preorder traversal algorithm using a stack instead of recursion.

Rewrite the binary tree preorder traversal algorithm using a stack instead of recursion.