convertFormField = function (formField, splitPart, parentField) {
      var convertedField = null;

      var keepField = formField.root ||
          (splitPart === 'all') ||
          (parentField && parentField.key &&
            (parentField.type === 'selectfieldset')) ||
          (formField.type && formField.type === 'help');
      if (!keepField) {
        keepField = (splitPart === 'included') && includeFormField(formField);
      }
      if (!keepField) {
        keepField = (splitPart === 'excluded') && excludeFormField(formField);
        if (keepField && !options.excludeCoupledKeys) {
          keepField = !includeFormField(formField);
        }
      }
      if (!keepField) {
        return null;
      }

      var childPart = splitPart;
      if ((childPart === 'included') &&
          !options.excludeCoupledKeys &&
          !formField.root) {
        childPart = 'all';
      }

      // Make a shallow copy of the field since we will preserve all of its
      // properties (save perhaps "items")
      convertedField = _.clone(formField);

      // Recurse through the descendants of the field
      if (convertedField.items) {
        convertedField.items = _.map(convertedField.items, function (field) {
          return convertFormField(field, childPart, convertedField);
        });
        convertedField.items = _.compact(convertedField.items);
      }
      return convertedField;
    }
Converts the provided form field for inclusion in the included/excluded
portion of the result. The function returns null if the field should not
appear in the relevant part.

Note the function is recursive.

@function
@param {Object} formField The form field to convert
@param {string} splitPart The targeted result part, one of "included",
 "excluded", or "all". The "all" string is used in recursions to force
 the inclusion of the field even if it does not reference one of the
 provided keys.
@param {Object} parentField Pointer to the form field parent. This
 parameter is used in recursions to preserve direct children of a
 "selectfieldset".
@return {Object} The converted field.