def flatten_inplace(seq):
    """Flatten a sequence in place."""
    k = 0
    while k != len(seq):
        while hasattr(seq[k], '__iter__'):
            seq[k:k + 1] = seq[k]
        k += 1
    return seq
