def inorderTraversal(self, root):
        result, stack, current, last_traversed = [], [], root, None
        while stack or current:
            if current:
                stack.append(current)
                current = current.left
            else:
                parent = stack[-1]
                if parent.right in (None, last_traversed):
                    if parent.right is None:
                        result.append(parent.val)
                    last_traversed = stack.pop()
                else:
                    result.append(parent.val)
                    current = parent.right
        return result
dataset/ETHPy150Open kamyu104/LeetCode/Python/binary-tree-inorder-traversal.py/Solution2.inorderTraversal/original