<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def overlay(upper, lower):
 """Return the overlay of `upper` dict onto `lower` dict. This operation is similar to `dict.update`, but recurses when it encounters a dict/mapping, as to allow nested leaf values in the lower collection which are not in the upper collection. Whenever the upper collection has a value, its value is used. {'a': 0} True True """

    result = {}
    for key in upper:
        if is_mapping(upper[key]):
            lower_value = lower.get(key, {})
            if not is_mapping(lower_value):
                msg = 'Attempting to overlay a mapping on a non-mapping: {}'
                raise ValueError(msg.format(key))
            result[key] = overlay(upper[key], lower_value)
        else:
            result[key] = upper[key]
    for key in lower:
        if key in result:
            continue
        result[key] = lower[key]
    return result