private <A> void crossover(
		final MSeq<Chromosome<G>> c1,
		final MSeq<Chromosome<G>> c2,
		final int index
	) {
		@SuppressWarnings("unchecked")
		final TreeNode<A> tree1 = (TreeNode<A>)TreeNode.ofTree(c1.get(index).gene());
		@SuppressWarnings("unchecked")
		final TreeNode<A> tree2 = (TreeNode<A>)TreeNode.ofTree(c2.get(index).gene());

		crossover(tree1, tree2);

		final var flat1 = FlatTreeNode.ofTree(tree1);
		final var flat2 = FlatTreeNode.ofTree(tree2);

		@SuppressWarnings("unchecked")
		final var template = (TreeGene<A, ?>)c1.get(0).gene();

		final var genes1 = flat1.map(tree -> gene(template, tree));
		final var genes2 = flat2.map(tree -> gene(template, tree));

		c1.set(index, c1.get(index).newInstance(genes1));
		c2.set(index, c2.get(index).newInstance(genes2));
	}
Constructs a tree crossover with a given recombination probability.

@param probability the recombination probability
@throws IllegalArgumentException if the {@code probability} is not in the
         valid range of {@code [0, 1]}
jenetics.ext/src/main/java/io/jenetics/ext/TreeCrossover.java