class ConcurrentTree extends ConcurrentTreeNode<K, V> {

	public synchronized V remove(final K[] path) {
		ConcurrentTreeNode<K, V> node = getNode(path);
		if (node == null) {
			return null;
		}
		final V value = node.getValue();
		node.setValue(null);

		// Remove the nodes as long as they contain nor sub-nodes neither
		// value, and they have parent
		ConcurrentTreeNode<K, V> parent;
		while (node.getChildren().isEmpty() && (node.getValue() == null)
				&& ((parent = node.getParent()) != null)) {
			parent.removeChild(node.getKey());
			node = parent;
		}

		return value;
	}

}