preorder(node) if (node = null) return visit(node) preorder(node.left) preorder(node.right) iterativePreorder(node) if (node = null) return s ← empty stack s.push(node) while (not s.isEmpty()) node ← s.pop() visit(node) //right child is pushed first so that left is processed first if (node.right ≠ null) s.push(node.right) if (node.left ≠ null) s.push(node.left)