grouping the children of alternates when rewriting deeper levels