Add reduce() for building up a new value from a tree.

Adds a versions of reduce(), which builds up a single value by doing a postorder walk. When a node is visited, it is passed a collection of results from its subtrees. The original `memo` argument to `reduce` is passed to the visitor function when leaf nodes are visited.