def _first_of_type(args, kind):
    """Return either first object of type 'kind' or raise if not found."""
    for arg in args:
        if isinstance(arg, kind):
            return arg

    raise ValueError("This should be unreachable.")
Return either first object of type 'kind' or raise if not found.
xarray/computation/apply_ufunc.py