This code causes Stackoverflow error:
lazy val leftChild = new Node(true, root, Seq(2), Seq())
lazy val rightChild = new Node(true, root, Seq(3), Seq())
lazy val root :Node = new Node(false, null, Seq(1), Seq(leftChild, rightChild))
where Node is defined as follows:
case class Node(isLeaf: Boolean, parent: Node, keys: Seq[Int], pointers: Seq[Node])
One possible solution would be to resign from using case class. How to properly implement this structure using immutable states only? Is this possible with lazy and Node as case class?