from typing import Union
from typing import List


def max_length_v2(obj: Union[int, List]) -> int:
    """Return the maximum length of any list in nested list <obj>.

    The *maximum length* of a nested list is defined as:
    1. 0, if <obj> is a number.
    2. The maximum of len(obj) and the lengths of the nested lists contained
       in <obj>, if <obj> is a list.

    >>> max_length_v2(17)
    0
    >>> max_length_v2([1, 2, 3, 17])
    4
    >>> max_length_v2([[1, 2, 3, 3], 4, [4, 5]])
    4
    >>> max_length_v2([2, [2, 2, 2], 2, 3, [3, 4], 5, 6])
    7
    >>> max_length_v2([3, 1, [1, [2, 3, 4, 5, 6, 7], 4]])
    6
    """
    if isinstance(obj, int):
        return 0
    elif obj == []:
        return 0
    else:
        # obj is a list.
        return max(len(obj), max(max_length_v2(x) for x in obj))

    # version 2.. intuitive
    # if isinstance(obj, int):
    #     return 0
    # else:
    #     # obj is a list.
    #     len_lst = len(obj)
    #     for item in obj:
    #         # item is either an int or another list.
    #         len_lst = max(len_lst, max_length_v2(item))
    # return len_lst