from collections.abc import Sequence


def _flatten(lst):
    """Flatten sublists in list.
    see https://stackoverflow.com/a/952952/130164
    """

    entries = []
    for sublist in lst:
        # may be a sublist
        if isinstance(sublist, Sequence) and not isinstance(
            sublist, (str, bytes, bytearray)
        ):
            # recursively flatten sublist
            entries.extend(_flatten(sublist))
        else:
            # just an item
            entries.append(sublist)
    return entries