```
class Solution(object):
def __init__(self):
self.sum = 0 # sum of greater nums
def convertBST(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
self.traversal(root)
return root
def traversal(self, node):
if not node:
return
self.traversal(node.right)
val = node.val
node.val += self.sum
self.sum += val
self.traversal(node.left)
```