function keyReduce(out, key, range) {
    if (!isNumber(key)) {
        return range;
    }

    /* eslint-disable no-param-reassign */
    key = +key;
    if (range) {
        if (key - 1 === range.to) {
            range.to = key;
        }

        else if (key + 1 === range.from) {
            range.from = key;
        }

        else {
            range = null;
        }
    }

    if (!range) {
        range = {to: key, from: key};
        out[out.length] = range;
    }
    /* eslint-enable no-param-reassign */

    return range;
}
@param {Number|String} key must be a number