<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_unicode_optional_iterator(x):
 """ Raise TypeError if x is a str containing non-utf8 bytes or if x is an iterable which contains such a str. """

    if isinstance(x, STRING_TYPES):
        return to_unicode(x)

    try:
        l = list(x)
    except TypeError as e:
        assert 'is not iterable' in str(e)
        return x
    else:
        return [ to_unicode(e) for e in l ]