def search_caches(key, cache_list, raise_error=True):
    """Find UUID if it is in the cache_list dicts

    Parameters
    ----------
    key : str
        the UUID we're looking for
    cache_list : mapping or list of mapping
        caches that the objects are stored in (will be searched in order of
        the list). Mapping is {uuid: object}
    raise_error : bool
        whether to raise a KeyError if UUID not found; default True. If
        False, object not found returns None

    Returns
    -------
    object or None
        the object with the given UUID, or ``None`` if the object is not
        found and ``raise_error`` is ``False``.
    """
    if key is None:
        return None  # some objects allow UUID to be None
    if not isinstance(cache_list, list):
        cache_list = [cache_list]
    obj = None
    for cache in cache_list:
        if key in cache:
            obj = cache[key]
            break
    if obj is None and raise_error:
        raise KeyError("Missing key: " + str(key))
    return obj