Fixed logic that combines child layers into one layer if they appear sequentially.