def search(d, key, default=None):
    """Return a dict containing to the specified key in the (possibly
    nested) within dictionary d. If there is no item with that key, return
    default.
    """
    stack = [d]
    while stack:
        cur_d = stack[-1]
        stack.pop()
        for k, v in cur_d.items():
            if k == key:
                return cur_d
            elif isinstance(v, dict):
                stack.append(v)
    return default