def from_field(mapper, *fields):
    """Extract a `field` from a given item.

    If more than one `field` is given, select fields recursively.

    Examples:
        >>> def noop(data):
        ...     return data

        >>> mapper = from_field(noop, 'foo')
        >>> data = {'foo': 4}
        >>> mapper(data)
        4

        >>> mapper = from_field(noop, 'foo', 'bar')
        >>> data = {'foo': {'bar': 4}}
        >>> mapper(data)
        4
    """

    def decorator(response):
        context = response
        for field in fields:
            context = context.get(field)
        return mapper(context)

    return decorator