def recurse_data(data, keys, bucket=None, handler=None):
    """
    Performs a recursive search in data for values named by any key.
    If no such keys are present at root level, goes deeper into bucket values.
    If handler given, calls handler with each found value and key, otherwise
    returns the first found value.
    Both data and bucket contents can be dicts or lists or tuples.
    """
    if not isinstance(data, (dict, list, tuple)): return None
    datas = data if isinstance(data, (list, tuple)) else [data]
    for item in [x for x in datas if isinstance(x, dict)]:
        for key in keys:
            if key in item:
                if handler: handler(item, key)
                else: return item[key]
        if bucket in item: return recurse_data(item[bucket], keys, bucket)
    return None