public void put(long key) {
        if (key < 0) {
            throw new IndexOutOfBoundsException();
        }
        if (root == null) {
            size++;
            root = new RBNode(key,null);
        }
        RBNode node = root;

        while (true) {

            if (key == node.key) {
                return;
            }
            else if (key < node.key) {
                if (node.left != null) {
                    node = node.left;
                }
                else {
                    size++;
                    node.left = new RBNode(key, node);
                    fixAfterInsertion(node.left);
                    return;
                }
            }
            else {
                if (node.right != null) {
                    node = node.right;
                }
                else {
                    size++;
                    node.right = new RBNode(key, node);
                    fixAfterInsertion(node.right);
                    return;
                }
            }
        }
    }
Adds the given key to the set.
@param key the key to add to the set.
@exception IndexOutOfBoundsException thrown if the given key is not
in the range [0, maxKey].
Ghidra/Framework/Generic/src/main/java/ghidra/util/datastruct/RedBlackLongKeySet.java