def _domain_contains(d, val):
    """ Check whether a domain contains a given value

    Args:
        d:   Domain
        val: Value to check
    Returns:
        True if value is in the domain, False otherwise
    """
    if isinstance(d, (tuple, list)):
        for x in d:
            if isinstance(x, (list, tuple)):
                min, max = x
                if min <= val <= max:
                    return True
            elif x == val:
                return True
        return False
    return d == val