Gets the array item at a certain index, including multiple dimensions

@param {Array} arr The array to search
@param {Array<ExpressionStatement>} dimensions An array of indexes
@param {ExecutionContext} data The execution data context
@returns {Number|String}
@private
function getArrayIndexAt(arr, dimensions, data) {
    var currentDimension = dimensions[0];
    data.validate(currentDimension, 'number');
    currentDimension = Math.max(0, Math.floor(currentDimension - 1));

    if (arr.length <= currentDimension) throw new Error('Invalid array bounds');
    var item = arr[currentDimension];
    if (dimensions.length > 1) {
        if (!Array.isArray(item)) throw new Error('Invalid array dimensions');
        return getArrayIndexAt(arr[currentDimension], dimensions.slice(1), data);
    } else return item;
}