@Override
	public void linkNodes(K parentKey, K childKey, BiConsumer<TreeEntry<K, V>, TreeEntry<K, V>> consumer) {
		consumer = ObjectUtil.defaultIfNull(consumer, (parent, child) -> {
		});
		final TreeEntryNode<K, V> parentNode = nodes.computeIfAbsent(parentKey, t -> new TreeEntryNode<>(null, t));
		TreeEntryNode<K, V> childNode = nodes.get(childKey);

		// 1.子节点不存在
		if (ObjectUtil.isNull(childNode)) {
			childNode = new TreeEntryNode<>(parentNode, childKey);
			consumer.accept(parentNode, childNode);
			nodes.put(childKey, childNode);
			return;
		}

		// 2.子节点存在，且已经是该父节点的子节点了
		if (ObjectUtil.equals(parentNode, childNode.getDeclaredParent())) {
			consumer.accept(parentNode, childNode);
			return;
		}

		// 3.子节点存在，但是未与其他节点构成父子关系
		if (false == childNode.hasParent()) {
			parentNode.addChild(childNode);
		}
		// 4.子节点存在，且已经与其他节点构成父子关系，但是允许子节点直接修改其父节点
		else if (allowOverrideParent) {
			childNode.getDeclaredParent().removeDeclaredChild(childNode.getKey());
			parentNode.addChild(childNode);
		}
		// 5.子节点存在，且已经与其他节点构成父子关系，但是不允许子节点直接修改其父节点
		else {
			throw new IllegalArgumentException(StrUtil.format(
					"[{}] has been used as child of [{}], can not be overwrite as child of [{}]",
					childNode.getKey(), childNode.getDeclaredParent().getKey(), parentKey
			));
		}
		consumer.accept(parentNode, childNode);
	}
@Test
	public void linkNodesTest() {
		final ForestMap<String, String> map = new LinkedForestMap<>(false);
		map.linkNodes("a", "b");

		final TreeEntry<String, String> parent = map.get("a");
		final TreeEntry<String, String> child = map.get("b");

		assertNotNull(parent);
		assertEquals("a", parent.getKey());
		assertEquals(child, parent.getChild("b"));

		assertNotNull(child);
		assertEquals("b", child.getKey());
		assertEquals(parent, child.getDeclaredParent());
	}