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

    if (sum === undefined) {
      switch (config.number) {
        case 'number':
          return 0;

        case 'BigNumber':
          return new type.BigNumber(0);

        case 'Fraction':
          return new type.Fraction(0);

        default:
          return 0;
      }
    }

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