Perform a recursive rewrite.
The following pattern is pretty common throughout Mimir:
def replaceFooWithBar(e:Expression): Expression =
e match {
case Foo(a, b, c, ...) => Bar(a, b, c, ...)
case _ => e.recur(replaceFooWithBar(_))
}
Note how specific rewrites are applied to specific patterns
in the tree, and recur is used to ignore/descend through
every other class of object