from typing import Iterable


def flatten_iterable(its: Iterable, deep: bool = False) -> list:
    """
    flatten instance of Iterable to list
    Notes:
        1. except of str, won't flatten 'abc' to 'a', 'b', 'c'
    demo: [[[1], [2], [3]], 4]
        if deep is True: flatten to [1, 2, 3, 4]
        if deep is False, flatten to [[1], [2], [3], 4].
    """
    res = []
    for it in its:
        if isinstance(it, str):
            res.append(it)
        elif isinstance(it, Iterable):
            if deep:
                res += flatten_iterable(it, True)
            else:
                res.extend(it)
        else:
            res.append(it)
    return res