If curr node and it 's right child has same value
INDENT if ( node . right and node . right . val == node . val ) : NEW_LINE INDENT Rightmax += right + 1 NEW_LINE DEDENT ans [ 0 ] = max ( ans [ 0 ] , Leftmax + Rightmax ) NEW_LINE return max ( Leftmax , Rightmax ) NEW_LINE DEDENT