def _get_metric_value(nested_dict, metric_name):
    """Gets the value of the named metric from a slice's metrics."""
    for key in nested_dict:
        if metric_name in nested_dict[key]['']:
            typed_value = nested_dict[key][''][metric_name]
            if 'doubleValue' in typed_value:
                return typed_value['doubleValue']
            if 'boundedValue' in typed_value:
                return typed_value['boundedValue']['value']
            raise ValueError('Unsupported value type: %s' % typed_value)
        else:
            raise ValueError('Key %s not found in %s' % (metric_name, list(
                nested_dict[key][''].keys())))
