def concatenate_or_append(value, output):                           # O(1)
    """
    Either concatenate a list or append to it, in order to keep list flattened
    as list of lists

    >>> concatenate_or_append([42], [])
    [[42]]
    >>> concatenate_or_append([[42, 49]], [[23, 35]])
    [[23, 35], [42, 49]]
    """
    if isinstance(value[0], list):                                  # O(1)
        output += value                                             # O(1)
    else:                                                           # O(1)
        output.append(value)                                        # O(1)

    return output                                                   # O(1)