def flatten_list(nested_list, list_types=(list, tuple), return_type=list):
    """Flatten `nested_list`.

    All the nested lists in `nested_list` will be flatten, and the elements
    in all these lists will be gathered together into one new list.

    Parameters
    ----------
    nested_list : list | tuple
        The (maybe) nested list to be flatten.

    list_types : tuple[type]
        Types to be regarded as lists. (default is `(list, tuple)`)

    return_type : type
        The returning list type. (default is `list`)
    """
    ret = []
    stack = [nested_list]
    while stack:
        top = stack.pop()
        if isinstance(top, list_types):
            stack.extend(reversed(top))
        else:
            ret.append(top)
    return return_type(ret)