function firstSequentially(items, beginProcessItem) {

        var masterDeferred = new $.Deferred();

        function doItem(i) {
            if (i >= items.length) {
                masterDeferred.reject();
                return;
            }

            beginProcessItem(items[i], i)
                .fail(function () {
                    doItem(i + 1);
                })
                .done(function () {
                    masterDeferred.resolve(items[i]);
                });
        }

        doItem(0);
        return masterDeferred.promise();
    }
Executes a series of tasks in serial (task N does not begin until task N-1 has completed).
Returns a "master" Promise that is resolved when the first task has resolved. If all tasks
fail, the master Promise is rejected.

@param {!Array.<*>} items
@param {!function(*, number):Promise} beginProcessItem
@return {$.Promise}