I have the following XML:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Container>
    <Item type="forest"/>
    <Item type="tree"/>
    <Item type="branch"/>
    <Item type="leaf"/>
    <Item type="branch"/>
    <Item type="leaf"/>
    <Item type="leaf"/>
    <Item type="tree"/>
    <Item type="branch"/>
    <Item type="branch"/>
    <Item type="leaf"/>
    <Item type="forest"/>
    <Item type="tree"/>
    <Item type="branch"/>
    <Item type="leaf"/>
</Container>

```

The data represents the following structure:

1. Each forest has trees, each tree has branches, each branch has leaves.
2. A change in tag signifies the next item at the level above.

For the given XML:

1. There are 2 forests.
2. The first forest has 2 trees.
3. The first tree of the first forest has 2 branches, each of which has the same number of leaves as its 1-based index.

I want to process the data in XSLT similar to the following, had the type attributes been tag names:

```xml
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xsl:template match='/'>
        <xsl:for-each select="/Container/forest">
            <xsl:for-each select="tree">
                <xsl:for-each select="branch">
                    <xsl:for-each select="leaf">
                    </xsl:for-each>
                </xsl:for-each>
            </xsl:for-each>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

```

How can this be achieved?