function remove_index(map, id) {
    let count = 0;


    if (is_array(map)) {
        for (let x = 0, arr, index, found; x < map.length; x++) {
            if ((arr = map[x]) && arr.length) {
                if ("undefined" == typeof id) {
                    return 1;
                } else {
                    index = arr.indexOf(id);
                    if (0 <= index) {
                        if (1 < arr.length) {
                            arr.splice(index, 1);

                            return 1;
                        } else {

                            delete map[x];
                            if (count) {
                                return 1;
                            }
                            found = 1;
                        }
                    } else {
                        if (found) {
                            return 1;
                        }
                        count++;
                    }
                }
            }
        }
    } else for (let item of map.entries()) {
        const key = item[0],
              value = item[1],
              tmp = remove_index(value, id);

        tmp ? count++ : map.delete(key);
    }

    return count;
}
When called without passing ID it just will clean up
@param {!Map|KeystoreMap|Array<number|string|Array<number|string>>} map
@param {!number|string=} id
@return {number}