def unlistify(x):
    """Convert a list of one element into that element.
       No-op on list of multiple elements."""
    if not isinstance(x, (list, tuple)):
        raise TypeError("unlistify expects a list or tuple")
    if len(x) == 1:
        return x[0]
    else:
        return x