It's a simple XSLT transformation something like this (which you apply to document a.xml):
<xsl:variable name="docB" select="document('b.xml')"/><xsl:template match="Root"><Root><xsl:apply-templates/></Root></xsl:template><xsl:template match="Root/LeafA"><xsl:copy-of select="*"/><xsl:copy-of select="$docB/Root/LeafA/*"/></xsl:template><xsl:template match="Root/LeafB"><xsl:copy-of select="*"/><xsl:copy-of select="$docB/Root/LeafB/*"/></xsl:template>