Add Rewriter

## Overview

This pull request adds walk-and-replace helpers called `Rewrite()` and `RewriteFunc()`. These allow a `Rewriter` or a function to recursively rewrite and update an AST hierarchy.

This will be used for some query rewriting needed in evaluating conditionals.