Number of all labeled, unordered rooted trees with $n$ vertices and $k$ leaves. I've been trying to do the following exercise:

The problem

Find the number of all labeled, unordered rooted trees with $n$ vertices and $k$ leaves.

I know that I should try to write an equality for the generating function $T(z,y)$ where we use the following weight for a tree $W$ with $n$ vertices and $k$ leaves:
$\omega(W) = z^{n}y^{k}$
and thus we have $T(z,y) = {\sum}_{_W}\omega(W)$. 
After writing the equality I should use the lagrange inversion formula (this is a hint given in the exercise). 

My problem
I have troubles with writing the equality for $T(z,y)$. First I tried to write down the first terms of $T(z,y)$ - to look for patterns. Then I tried to write the species of labeled unrooted trees in terms of other species. In both cases I ended up getting more confused.
Could someone give a hint for writing the equation for $T(z,y)$? How do I handle such problems? 
 A: Use the analytic method. Your class is a root connected to a non-empty set of trees, or a leaf. Use $\mathcal{Z}$ (and $z$) for inner nodes, $\mathcal{Y}$ (and $y$) for leaves; use $\mathcal{E}$ for the class with one empty object:
$$
\mathcal{T}
  = \mathcal{Z} \star (\mathfrak{S}(\mathcal{T}) \smallsetminus \mathcal{E})
      + \mathcal{Z} \mathcal{Y}
$$
This translates to:
$$
T(z, y) = z (e^{T(z, y)} - 1) + z y
$$
Just need to get $T(z, y)$ (or the coefficients) out of this...
A: We start with the combinatorial class
$$\def\textsc#1{\dosc#1\csod}
\def\dosc#1#2\csod{{\rm #1{\small #2}}}\mathcal{T} =
\mathcal{Z} \times \mathcal{Y}  +
\mathcal{Z}\times \textsc{SET}_{\ge 1}(\mathcal{T}).$$
This translates into the functional equation
$$T(z) = zy + z\times(\exp T(z) - 1) = z\times(-1+y+\exp T(z))$$
or
$$z = \frac{T(z)}{-1+y+\exp T(z)}.$$
Writing
$$T(z) = \sum_{n\ge 1} T_n(y) \frac{z^n}{n!}$$
we  are interested  in  extracting coefficients as per the residue
operator
$$\frac{1}{(n-1)!} T_n(y) = [z^{n-1}] T'(z) =
\; \underset{z}{\mathrm{res}} \; \frac{1}{z^{n}} T'(z).$$
Now we put $w=T(z)$ so that $dw  = T'(z) \; dz$ and use the functional
equation to obtain
$$\; \underset{w}{\mathrm{res}} \;\frac{(-1+y+\exp w)^n}{w^{n}}$$
Extracting the coefficient on $[y^k]$ we find
$$[y^k] \; \underset{w}{\mathrm{res}}
\;\frac{(-1+y+\exp w)^n}{w^{n}}
= {n\choose k} \; \underset{w}{\mathrm{res}} \;
\frac{(\exp(w)-1)^{n-k}}{w^{n}}.$$
This yields
$$[y^k] T_n(y) = (n-1)! {n\choose k}
[w^{n-1}] (\exp(w)-1)^{n-k}
\\ = \frac{n!}{k!}
(n-1)! [w^{n-1}] \frac{(\exp(w)-1)^{n-k}}{(n-k)!}.$$
We  recognize the  EGF of  the Stirling  numbers of  the second  kind,
getting
$$\bbox[5px,border:2px solid #00A000]{
\frac{n!}{k!} {n-1\brace n-k}.}$$
This is the residue operator from Egorychev's Combinatorial sums.
 As a sanity check we find for the number of all rooted trees
$$\sum_{k=1}^n
(n-1)! {n\choose k}
[w^{n-1}] (\exp(w)-1)^{n-k}
\\ = (n-1)! [w^{n-1}]
\sum_{k=1}^n {n\choose k} (\exp(w)-1)^{n-k}.$$
Now for $k=0$ we get
$$(n-1)! [w^{n-1}] (\exp(w)-1)^n = 0$$
because $\exp(w)-1 = w + \cdots.$ Hence we may continue with
$$(n-1)! [w^{n-1}]
\sum_{k=0}^n {n\choose k} (\exp(w)-1)^{n-k}
= (n-1)! [w^{n-1}] \exp(nw) \\ = (n-1)! \frac{n^{n-1}}{(n-1)!}
= n^{n-1}$$
and the check goes through (Cayley's formula).
