Returns the current frame in a mapping given a key mapping.

    Args:
        obj: Nested Dimensioned object
        key_map: Dictionary mapping between dimensions and key value
        cached: Whether to allow looking up key in cache

    Returns:
        The item in the mapping corresponding to the supplied key.

def get_plot_frame(map_obj, key_map, cached=False):
    """Returns the current frame in a mapping given a key mapping.

    Args:
        obj: Nested Dimensioned object
        key_map: Dictionary mapping between dimensions and key value
        cached: Whether to allow looking up key in cache

    Returns:
        The item in the mapping corresponding to the supplied key.
    """
    if map_obj.kdims and len(map_obj.kdims) == 1 and map_obj.kdims[0] == 'Frame':
        # Special handling for static plots
        return map_obj.last
    key = tuple(key_map[kd.name] for kd in map_obj.kdims if kd.name in key_map)
    if key in map_obj.data and cached:
        return map_obj.data[key]
    else:
        try:
            return map_obj[key]
        except KeyError:
            return None
        except StopIteration as e:
            raise e
        except Exception:
            print(traceback.format_exc())
            return None