def __flatten(ls):
    """
    Aux function to flatten lists and remove None from result (k, v) sequences
    :param ls: original list
    :return: flattened list
    """
    for e in ls:
        if type(e) is list:
            for i in e:
                yield i
        elif type(e) is tuple:
            yield e
