Branch visitors for detecting and mutating branches.

This PR replaces #547. The branch has been renamed to correspond to the name of the main file this adds.  I have addressed most of the comments that were still open in #547, and made some modifications that are dependent on PR #551.

Should be 4-space indents.