The following code implements a Bird-style traversal replaceMin which traverses a
tree exactly once to produce a new tree of the same shape with the leaves replaced with
the minimum of all leaf values in the original tree.
import System.IO (fixIO)
data Tree a = Leaf a | Branch (Tree a) (Tree a)