in src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java [1308:1338]
private void insertValue(final Node<K, V> newNode) throws IllegalArgumentException {
Node<K, V> node = rootNode[VALUE.ordinal()];
while (true) {
final int cmp = compare(newNode.getValue(), node.getValue());
if (cmp == 0) {
throw new IllegalArgumentException(
"Cannot store a duplicate value (\"" + newNode.getData(VALUE) + "\") in this Map");
}
if (cmp < 0) {
if (node.getLeft(VALUE) == null) {
node.setLeft(newNode, VALUE);
newNode.setParent(node, VALUE);
doRedBlackInsert(newNode, VALUE);
break;
}
node = node.getLeft(VALUE);
} else { // cmp > 0
if (node.getRight(VALUE) == null) {
node.setRight(newNode, VALUE);
newNode.setParent(node, VALUE);
doRedBlackInsert(newNode, VALUE);
break;
}
node = node.getRight(VALUE);
}
}
}