<s> class Solution ( object ) : <EOL> def longestConsecutive ( self , root ) : <EOL> """<STR_LIT>""" <EOL> self . max_len = <NUM_LIT:0> <EOL> def longestConsecutiveHelper ( root ) : <EOL> if not root : <EOL> return <NUM_LIT:0> <EOL> left_len = longestConsecutiveHelper ( root . left ) <EOL> right_len = longestConsecutiveHelper ( root . right ) <EOL> cur_len = <NUM_LIT:1> <EOL> if root . left and root . left . val == root . val + <NUM_LIT:1> : <EOL> cur_len = max ( cur_len , left_len + <NUM_LIT:1> ) ; <EOL> if root . right and root . right . val == root . val + <NUM_LIT:1> : <EOL> cur_len = max ( cur_len , right_len + <NUM_LIT:1> ) <EOL> self . max_len = max ( self . max_len , cur_len , left_len , right_len ) <EOL> return cur_len <EOL> longestConsecutiveHelper ( root ) <EOL> return self . max_len </s>
