@Override
	public boolean remove(short key) {

        if ((key < 0) || (key >= size)) {
            throw new IndexOutOfBoundsException();
        }

        // compute the leaf node index.
        int nodeIndex = power2+key;

        // clear the leaf bit to indicate that the key is not in the set.
        // if it is already "off", then we don't have to do anything
        if (!clearBit(nodeIndex)) {
            return false;
        }

        // decrement the number of keys in the set
        numKeys--;


        // traverse up the tree, clearing any parent nodes if all its child
        // nodes are "off".
        while(nodeIndex != 1) {
            nodeIndex /= 2;
            if (!isBitSet(nodeIndex)) {
                return true;
            }
            if (isBitSet(nodeIndex*2) || isBitSet(nodeIndex*2+1)) {
                return true;
            }
            clearBit(nodeIndex);
        }
        return true;
    }
Removes the key from the set.
@param key The key to remove.
@exception IndexOutOfBoundsException if the given key is not
in the range [0, size-1].
Ghidra/Framework/Generic/src/main/java/ghidra/util/datastruct/BitTree.java