Let's add a TODO: I think this algorithm is not using mutability. It could work almost exactly the same with List[Value] and vals everywhere.