Isn't sorting always a requirement for removing duplicates without needing an arbitrary amount of buffer space? If you could prove that there were no duplicates (for instance, each side had different literals), then turning it into UnionAll would seem sensible.