Adding utility functions for detecting and manipulating branches.

This PR pulls out some of the helper routines from the specialized_branched_loops code in PR #482 and provides some correctness testing for these visitors and mutators. These functions might be useful in other contexts, but the main reason for pulling them out into their own file is to help the readability of the specialize_branched_loops code, and make it easier to test them independently.
This visitor appears to substitute in let values, which is usually not safe. You should at least add a comment justifying why it's safe in this context (if it is).