# 一些BST题目甚至可以先中序存为list, 再从list中找到最近的
class Solution(object):
def closestValue(self, root, target):
res = None
cur = root
while cur:
# 更直接的思路: 记录遍历过程中距离, 并记录更新距离最小的dian
if res is None or abs(res - target) > abs(cur.val - target):
res = cur.val
if cur.val > target:
cur = cur.left
else:
cur = cur.right
return res