What are efficient ways to compute the derivatives of iterated functions?
An unordered hierarchical partition of $n \geq 2$ is composed out of two ingredients:


A non-trivial partition $n_1,\ldots,n_k \vdash n$, where $n_1 \leq \cdots \leq n_k$ and $k &gt; 1$.
For each $n_i$, an unordered hierarchical partition of $n_i$. Furthermore, if $n_i = n_{i+1}$ then in some fixed order of hierarchical partitions of $n_i$, the one chosen for $n_i$ must precede or equal the one chosen for $n_{i+1}$.


In the base case $n = 1$ there is a single unordered hierarchical partition.

This gives the following algorithm for generating all unordered hierarchical partitions. We generate a list $P^{(n)}_1,\ldots,P^{(n)}_{q(i)}$ of all $q(n)$ unordered hierarchical partitions of $n$. For $n = 1$, the list consists of the single trivial partition. In order to generate the list for $n$:


Go over all non-trivial partitions $n_1,\ldots,n_k \vdash n$. We can write this partition more succinctly as $1^{m_1},\ldots,(n-1)^{m_{n-1}}$, where $m_i$ is the multiplicity of $i$.
For each $i \in \{1,\ldots,n-1\}$, make a list of all non-decreasing sequences of length $m_i$ consisting of numbers in $\{1,\ldots,q(i)\}$; there are $\binom{q(i)+m_i-1}{q(i)}$ of these.
Each choice of one sequence for each $i$ from the corresponding list corresponds to one unordered hierarchical partition of $n$.