Specialize branched loops

Continuation of PR #469 inside the main repo.
I'm not opposed to this, I'd just like to understand why this particular PR added this?