def get_single_value(values):
    """
    Given a sequence of values, checks that all values are the same, and then returns the single
    value. The values must satisfy transitive equality.
    """
    iterator = iter(values)
    try:
        value = next(iterator)
    except StopIteration:
        raise ValueError('values cannot be of length zero.')
    try:
        next_value = next(iterator)
        if value != next_value:
            raise ValueError('Not all elements in values are equal.')
    except StopIteration:
        pass
    return value
