def METHOD_NAME(self, field, search_value, search_field="name", collection_id=None):
    """Return a list of the specified field for records whose search_field match search_value
    and filtered by collection if collection has been provided.
    If field is None, return the whole record for each match.
    """
    matches = self._get_matches(search_value, search_field, collection_id)
    if not field:
        return matches
    field_matches = []
    for match in matches:
        # if there are no custom fields, then `match` has no key 'fields'
        if 'fields' in match:
            custom_field_found = False
            for custom_field in match['fields']:
                if field == custom_field['name']:
                    field_matches.append(custom_field['value'])
                    custom_field_found = True
                    break
            if custom_field_found:
                continue
        if 'login' in match and field in match['login']:
            field_matches.append(match['login'][field])
            continue
        if field in match:
            field_matches.append(match[field])
            continue
    if matches and not field_matches:
        raise AnsibleError("field {field} does not exist in {search_value}".format(field=field, search_value=search_value))
    return field_matches