```
class Solution:
# @param root, a tree node
# @return nothing, do it in place
def flatten1(self, root):
if not root:
return
self.flatten(root.left)
self.flatten(root.right)
if root.left:
temp = root.right
root.right = root.left
root.left = None
while root.right:
root = root.right
root.right = temp
```