mergeValue = ({ currentValue, documentValue, deletedValues: deletedFields, path, locale, datatype }) => {
  if (locale) {
    // note: intl fields are of type Object but should be treated as Strings
    return currentValue || documentValue || '';
  }

  // note: retrieve nested deleted values is performed here to avoid skipping
  // the merge in case the current field is not in `currentValues` but a nested
  // property has been removed directly by path
  const deletedValues = getNestedDeletedValues(path, deletedFields);
  const hasDeletedValues = !!size(deletedValues);
  if ((Array.isArray(currentValue) || hasDeletedValues) && find(datatype, ['type', Array])) {
    return merge([], documentValue, currentValue, deletedValues);
  } else if ((isPlainObject(currentValue) || hasDeletedValues) && find(datatype, ['type', Object])) {
    return merge({}, documentValue, currentValue, deletedValues);
  }
  return undefined;
}
Merges values. It takes into account the current, original and deleted values,
and the merge produces the proper type for simple objects or arrays.

@param {Object} props
 Form component props. Only specific properties for this function are documented.
@param {*} props.currentValue
 Current value of the field
@param {*} props.documentValue
 Original value of the field
@return {*|undefined}
 Merged value or undefined if no merge was performed