function recurse( ndims, shape, dim, indices, out, clbk, thisArg ) {
	var idx;
	var FLG;
	var S;
	var d;
	var i;

	// Check whether we're filling 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.push( clbk.call( thisArg, idx ) );
		} else {
			out.push( recurse( ndims, shape, d, idx, [], clbk, thisArg ) );
		}
	}
	return out;
}
Recursive fills an array.

@private
@param {NonNegativeInteger} ndims - number of dimensions
@param {NonNegativeIntegerArray} shape - array shape
@param {NonNegativeInteger} dim - dimension index
@param {NonNegativeIntegerArray} indices - outer array element indices
@param {Array} out - output array
@param {Function} clbk - callback function
@param {*} [thisArg] - callback execution context
@returns {Array} output array