function deepForEach (array, callback, skipIndex = false) {
  if (array.length === 0) {
    return
  }

  if (skipIndex) {
    recursiveForEach(array)
    return
  }
  const index = []
  recursiveForEachWithIndex(array, 0)

  function recursiveForEachWithIndex (value, depth) {
    if (Array.isArray(value)) {
      const N = value.length
      for (let i = 0; i < N; i++) {
        index[depth] = i
        recursiveForEachWithIndex(value[i], depth + 1)
      }
    } else {
      callback(value, index.slice(0, depth), array)
    }
  }
  function recursiveForEach (value) {
    if (Array.isArray(value)) {
      const N = value.length
      for (let i = 0; i < N; i++) {
        recursiveForEach(value[i])
      }
    } else {
      callback(value)
    }
  }
}
Recursively iterates over each element in a multi-dimensional array and applies a callback function.

@param {Array} array - The multi-dimensional array to iterate over.
@param {Function} callback - The function to execute for each element. It receives three arguments:
  - {any} value: The current element being processed in the array.
  - {Array<number>} index: The index of the current element in each dimension.
  - {Array} array: The original array being processed.
@param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.