title: Change node in Scala case class tree
body: <p>Assume that I have some tree build using case classes, something like that:</p>
  
  <pre><code>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))
  </code></pre>
  
  <p>And now I want to build a method to change the node with some id to another node. It's easy to find this node, but I don't know how to change it. Is there any simply way to do that?</p>