def _pick_by_cls(iterable, cls, assert_unique=True):
    """Get first obj from `iterable` whose class is `cls`."""
    instances = [obj for obj in iterable if isinstance(obj, cls)]
    if assert_unique:
        assert len(instances) == 1
    return instances[0]