def __add_parameter(self, param, path_parameters, params):
    """Adds all parameters in a field to a method parameters descriptor.

    Simple fields will only have one parameter, but a message field 'x' that
    corresponds to a message class with fields 'y' and 'z' will result in
    parameters 'x.y' and 'x.z', for example. The mapping from field to
    parameters is mostly handled by __field_to_subfields.

    Args:
      param: Parameter to be added to the descriptor.
      path_parameters: A list of parameters matched from a path for this field.
         For example for the hypothetical 'x' from above if the path was
         '/a/{x.z}/b/{other}' then this list would contain only the element
         'x.z' since 'other' does not match to this field.
      params: List of parameters. Each parameter in the field.
    """
    # If this is a simple field, just build the descriptor and append it.
    # Otherwise, build a schema and assign it to this descriptor
    descriptor = None
    if not isinstance(param, messages.MessageField):
      name = param.name
      descriptor = self.__parameter_descriptor(param)
      descriptor['location'] = 'path' if name in path_parameters else 'query'

      if descriptor:
        params[name] = descriptor
    else:
      for subfield_list in self.__field_to_subfields(param):
        name = '.'.join(subfield.name for subfield in subfield_list)
        descriptor = self.__parameter_descriptor(subfield_list[-1])
        if name in path_parameters:
          descriptor['required'] = True
          descriptor['location'] = 'path'
        else:
          descriptor.pop('required', None)
          descriptor['location'] = 'query'

        if descriptor:
          params[name] = descriptor