function permutationGrouping(knownBitPermutationFunc, height) {
    let seen = new Set();
    let result = [];
    for (let i = 0; i < height; i++) {
        let mask = 0;
        let j = i;
        while (!seen.has(j)) {
            seen.add(j);
            mask |= 1 << j;
            j = knownBitPermutationFunc(j);
        }
        if (mask !== 0) {
            result.push(mask);
        }
    }
    return result;
}
@param {!function(!int) : !int} knownBitPermutationFunc Returns the output of the permutation for a
    given input, assuming the gate is exactly sized to the overall circuit.
@param {!int} height
@returns {!Array.<!int>}