Add tree mutation implementation and tests