def _format_marker(marker, first=True):
    assert isinstance(marker, (list, tuple, string_types))
    if (isinstance(marker, list) and (len(marker) == 1) and isinstance(marker[0], (list, tuple))):
        return _format_marker(marker[0])
    if isinstance(marker, list):
        inner = (_format_marker(m, first=False) for m in marker)
        if first:
            return ' '.join(inner)
        else:
            return (('(' + ' '.join(inner)) + ')')
    elif isinstance(marker, tuple):
        return ' '.join([m.serialize() for m in marker])
    else:
        return marker
def _format_marker(marker, first=True):
    assert isinstance(marker, (list, tuple, string_types))
    if (isinstance(marker, list) and (len(marker) == 1) and isinstance(marker[0], (list, tuple))):
        return _format_marker(marker[0])
    if isinstance(marker, list):
        inner = (_format_marker(m, first=False) for m in marker)
        if first:
            return ' '.join(inner)
        else:
            return (('(' + ' '.join(inner)) + ')')
    elif isinstance(marker, tuple):
        return ' '.join([m.serialize() for m in marker])
    else:
        return marker