Thanks for the reply, Aleš. In the case envisaged at the link I gave, the operation would not be needed until category X and/or Y became very large. At that point, if the intersection were still quite small it could be handled manually with assistance from WikiTree Plus along the lines you suggest. It's good to know that if the intersection were as large as thousands of profiles, you could add code to EditBot to handle it.