function _sum (array) {
    let sum

    deepForEach(array, function (value) {
      try {
        sum = (sum === undefined) ? value : add(sum, value)
      } catch (err) {
        throw improveErrorMessage(err, 'sum', value)
      }
    })

    // make sure returning numeric value: parse a string into a numeric value
    if (sum === undefined) {
      sum = numeric(0, config.number)
    }
    if (typeof sum === 'string') {
      sum = numeric(sum, safeNumberType(sum, config))
    }

    return sum
  }
Recursively calculate the sum of an n-dimensional array
@param {Array | Matrix} array
@return {number} sum
@private