function recurseLexicographic( orig, x, ndims, shape, dim, indices, out, stride, offset, clbk, thisArg ) { // eslint-disable-line max-params
	var FLG;
	var idx;
	var S;
	var d;
	var i;

	// Check whether we've reached the last dimension:
	d = dim + 1;
	FLG = ( d === ndims );

	S = shape[ dim ];
	for ( i = 0; i < S; i++ ) {
		idx = indices.slice(); // we explicitly copy in order to avoid potential mutation when calling `clbk`
		idx.push( i );
		if ( FLG ) {
			out[ offset ] = clbk.call( thisArg, x[ i ], idx, orig );
			offset += stride;
		} else {
			offset = recurseLexicographic( orig, x[ i ], ndims, shape, d, idx, out, stride, offset, clbk, thisArg );
		}
	}
	return offset;
}
Recursively flattens an array in lexicographic order.

@private
@param {Array} orig - original input array
@param {Array} x - array to flatten
@param {NonNegativeInteger} ndims - number of dimensions in the input array
@param {NonNegativeIntegerArray} shape - shape of the input array
@param {NonNegativeInteger} dim - dimension index
@param {NonNegativeIntegerArray} indices - outer array element indices
@param {Collection} out - output array
@param {integer} stride - output array stride
@param {NonNegativeInteger} offset - output array offset
@param {Function} clbk - callback function
@param {*} [thisArg] - callback execution context
@returns {NonNegativeInteger} offset for next output array element