Helper to convert a descriptor and a set of fields to a Protobuf instance

def _fields_to_object(descriptor, fields):
    'Helper to convert a descriptor and a set of fields to a Protobuf instance'
    # pylint: disable=protected-access
    obj = descriptor._concrete_class()

    for name, value in fields:
        if isinstance(value, tuple):
            subtype = descriptor.fields_by_name[name].message_type
            value = _fields_to_object(subtype, value)
        _assign_to_field(obj, name, value)

    return obj