Specialize branched loops

Continuation of PR #469 inside the main repo.
What about rewriting this sequence from this:

     size_t old_num_branches = branches.size();
     if (child.defined()) {
        include_stmt_or_expr(child);
    }

    if (branches.size() == old_num_branches) {
        ...
    } else {
        // Pull the child branches created by the collector out of the branch list.
        std::vector<Branch> child_branches(branches.begin() + old_num_branches, branches.end());
        branches.erase(branches.begin() + old_num_branches, branches.end());
    }

To something like this instead:

    std::vector<Branch> child_branches;
    if (child.defined()) {
        branches.swap(child_branches);
        include_stmt_or_expr(child);
        branches.swap(child_branches);
    }

    if (child_branches.empty()) {
        ...
    } else {
        // Don't need to do anything.
    }

The motivation for suggesting this is that vector::swap is very cheap, this might avoid the vector range copying/resizing. 

It also concentrates the logic for separating child branches from the original branches into one smaller step, so you may/may not consider this easier to read.