Out of interest is there a reason for having a single branch-controlling flag for 1/2/3 then doing all this copying and dropping of the flag? Visually it feels simpler if you do something like:
I felt it made it easier to describe. You could just use a simple template match.
In retrospect, your way is better, since the dups etc require space anyway.