At-most-\$n\$-ary trees are rooted trees where each internal node has between 1 and \$n\$ children (inclusive). Two trees are considered identical only if the shapes exactly match without re-ordering each node's children. In other words, the left-to-right order of children matters.
For example, the following is an example of an at-most-ternary tree (each node is marked with its out-degree, the leaves being zeros):
2 / \ 1 2 | / \ 3 0 1 /|\ | 0 0 0 0
Note that a single-node tree is a valid at-most-\$n\$-ary tree for any value of \$n\$, since it has no internal nodes.
Write a function or program that, given a positive integer \$n\$ (1st input), maps a natural number (2nd input) to a unique at-most-\$n\$-ary tree. It must be a bijection; every tree must have a unique natural number that maps to the tree. Only the code going from a number to a tree is considered for scoring, but it is recommended to provide the opposite side to demonstrate that it is indeed a bijection.
The output format for the tree is flexible (nested arrays, string/flat array representations including parentheses or prefix notation). You can also choose the "natural number" to start at 0 or 1.
Standard code-golf rules apply. The shortest code in bytes wins.