  We present a new algorithm for identifying the substructure within simulated
dark matter haloes. The method is an extension of that proposed by Tormen et
al. (2004) and Giocoli et al. (2008a), which identifies a subhalo as a group of
self-bound particles that prior to being accreted by the main progenitor of the
host halo belonged to one and the same progenitor halo (hereafter satellite).
However, this definition does not account for the fact that these satellite
haloes themselves may also have substructure, which thus gives rise to
sub-subhaloes, etc. Our new algorithm identifies substructures at all levels of
this hierarchy, and we use it to determine the mass function of all
substructure (counting sub-haloes, sub-subhaloes, etc.). On average, haloes
which formed more recently tend to have a larger mass fraction in substructure
and to be less concentrated than average haloes of the same mass. We provide
quantitative fits to these correlations. Even though our algorithm is very
different from that of Gao et al. (2004), we too find that the subhalo mass
function per unit mass at redshift z = 0 is universal. This universality
extends to any redshift only if one accounts for the fact that host haloes of a
given mass are less concentrated at higher redshifts, and concentration and
substructure abundance are anti-correlated. This universality allows a simple
parametrization of the subhalo mass function integrated over all host halo
masses, at any given time. We provide analytic fits to this function which
should be useful in halo model analyses which equate galaxies with halo
substructure when interpreting clustering in large sky surveys. Finally, we
discuss systematic differences in the subhalo mass function that arise from
different definitions of (host) halo mass.
