public RedBlackEntry<K, V> getOrCreateEntry(K key) {
		if (root == null) {
			size++;
			modCount++;
			root = new RedBlackEntry<K, V>(key, null, null);
			maxEntry = root;
			minEntry = root;
			return root;
		}

		if (key.compareTo(maxEntry.key) > 0) {
			size++;
			modCount++;
			RedBlackEntry<K, V> newNode = new RedBlackEntry<K, V>(key, null, maxEntry);
			maxEntry.right = newNode;
			maxEntry = newNode;
			fixAfterInsertion(maxEntry);
			return newNode;
		}

		RedBlackEntry<K, V> node = root;
		while (true) {
			int comp = key.compareTo(node.key);
			if (comp == 0) {
				return node;
			}
			else if (comp < 0) {
				if (node.left != null) {
					node = node.left;
				}
				else {
					size++;
					modCount++;
					RedBlackEntry<K, V> newNode = new RedBlackEntry<K, V>(key, null, node);
					node.left = newNode;
					if (node == minEntry) {
						minEntry = newNode;
					}
					fixAfterInsertion(node.left);
					return newNode;
				}
			}
			else {
				if (node.right != null) {
					node = node.right;
				}
				else {
					size++;
					modCount++;
					RedBlackEntry<K, V> newNode = new RedBlackEntry<K, V>(key, null, node);
					node.right = newNode;
					if (node == maxEntry) {
						maxEntry = newNode;
					}
					fixAfterInsertion(node.right);
					return newNode;
				}
			}
		}

	}
Adds the given key,value to the map. If the map does not allow duplicate keys and a key
already exists, the old value will be replaced by the new value and the old value will be
returned. 
@param key the key to add to the set.
@return the old value associated with the key, or null if the key was not previously in the map.
Ghidra/Framework/Generic/src/main/java/ghidra/util/datastruct/RedBlackTree.java