def flat(S):
    result = []
for item in S:
    if is_listlike(item) and len(item) > 0 and not is_listlike(item[0]):
        result.append(item)
else:
    result.extend(flat(item))
return result
tests = [[[[[1, 2, 3], ['a', 'b', 'c']]]], [[[1, 2, 3], ['a', 'b', 'c']]],
    [[[1, 2, 3]], [['a', 'b', 'c']]]]
for S in tests:
    pass
python: свести к списку списков, но не более