ケースクラスを使用して構築されたツリーがあるとします。
abstract class Tree
case class Branch(b1:Tree,b2:Tree, value:Int) extends Tree
case class Leaf(value:Int) extends Tree
var tree = Branch(Branch(Leaf(1),Leaf(2),3),Branch(Leaf(4), Leaf(5),6))
そして今、あるIDを持つノードを別のノードに変更するメソッドを構築したいと考えています。このノードを見つけるのは簡単ですが、変更方法がわかりません。それを行う簡単な方法はありますか?