class Solution(object):
def inorderTraversal(self, root):
"""
:type root: Optional[TreeNode]
:rtype: List[int]"""
result, stack =[], []
cur = root
while crr or stack:
while cur:
stack.append(cur)
cur = cur.left # 遍历左子树
cur = stack.pop()
result.append(cur.val)# 访问当前节点
cur = cur.right # 遍历右子树return result