If by leftmost you mean the 'z' node with the greatest depth, you could first define a variable to work out the depth of the left-most 'z', and then add the 'w' node when you match a node at such a depth
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Work out depth of left most 'z' node -->
<xsl:variable name="LeftMost">
<xsl:for-each select="//*[@name='z']">
<xsl:sort select="count(ancestor::*)" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="count(ancestor::*)"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:if test="@name='z' and count(ancestor::*) = $LeftMost">
<aaa name="w"/>
</xsl:if>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Using this, if you had two 'z' nodes at the same depth you would end up with both be given a 'w' node.
An alternative approach is to use generate-id() to get the ID of the fist 'z' at the greatest depth, and then add the 'w' when you match the node with the same id. This would then only add a 'w' node to the first 'z' node it finds at the greatest depth.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="LeftMost">
<xsl:for-each select="//*[@name='z']">
<xsl:sort select="count(ancestor::*)" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="generate-id()"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:if test="@name='z' and generate-id() = $LeftMost">
<aaa name="w"/>
</xsl:if>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>