P151: Enumeration of all rooted plane trees with at most $n$ vertices and the maximum degree $D$

P151: Enumeration of all rooted plane trees with at most $n$ vertices and the maximum degree $D$
Input:
Integers $n$ and $D$.
Output:
All rooted plane trees with at most $n$ vertices and the maximum degree $D$.
Complexity:
$O(1)$ time per tree with $O(n)$ space.
Comment:
A \textit{rooted plane tree} is a rooted tree with a left-to-right ordering specified for the children of each vertex.
Reference:
[Nakano2002] (Bibtex)