Simple Python solution (Recursive and Iterative Both)
Iterative approach using stack:\n\ndef preorderTraversal(self, root: Optional[TreeNode]) -> List[int]:\n        ans=[]\n        if root==None:\n            retu
**Iterative approach using stack:**\n```\ndef preorderTraversal(self, root: Optional[TreeNode]) -> List[int]:\n        ans=[]\n        if root==None:\n            return None\n        stack=[root]\n        while len(stack)>0:\n            temp=stack.pop(-1)\n            ans.append(temp.val)\n            if temp.right!=None:\n                stack.append(temp.right)\n            if temp.left!=None:\n                stack.append(temp.left)\n        return ans\n```\n\n**Recursive approach:**\n```\ndef preorderTraversal(self, root: Optional[TreeNode]) -> List[int]:\n\t\tans=[]\n        def preorder(root):\n            if root==None:\n                return None\n            ans.append(root.val)\n            preorder(root.left)\n            preorder(root.right)\n        preorder(root)\n        return ans\n```
['Binary Tree', 'Python']