2
def findMode(self, root):6
curr_num = float("inf")11
neighbor = curr_node.left12
while neighbor.right is not None:13
neighbor = neighbor.right14
neighbor.right = curr_node20
# since we deleted the left pointer when we were done processing in the previous if-block,21
# we know that we only reach this else case22
# if we've already processed this node.23
# Therefore, do the value processing here24
# and move to the right neighbor afterward25
if curr_node.val == curr_num:29
curr_num = curr_node.val31
if curr_streak == max_streak:32
result.append(curr_num)33
elif curr_streak > max_streak:34
max_streak = curr_streak37
curr_node = curr_node.right