Build domtree of new loops correctly

This fixes a bug introduced in r217525.