We can preserve the tree structure. But we only have to change the weights using genetic algorithm. DEAP might be of a help. But probably we should write the fitness function in Isabelle/ML.