public boolean replaceAtPath(final Path path, final TreeNode<T> child) {
		requireNonNull(path);
		requireNonNull(child);

		final Optional<TreeNode<T>> old = childAtPath(path);
		final Optional<TreeNode<T>> parent = old.flatMap(TreeNode::parent);

		parent.ifPresentOrElse(
			p -> p.replace(path.get(path.length() - 1), child),
			() -> {
				removeAllChildren();
				value(child.value());

				// Need to create a copy of the children, before attaching it.
				final List<TreeNode<T>> nodes = child._children != null
					? List.copyOf(child._children)
					: List.of();

				nodes.forEach(this::attach);
			}
		);

		return old.isPresent();
	}
Replaces the child at the given {@code path} with the given new
{@code child}. If no child exists on the given path, nothing is replaced.

@since 4.4

@param path the path of the child to replace
@param child the new child
@return {@code true} if a child at the given {@code path} existed and
        has been replaced
@throws NullPointerException if one of the given arguments is {@code null}
jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java