Define a perfect $N$-ary tree in math notation as a set of series Let's say I have a perfect $N$-ary tree of depth $=2 (M)$ and each parent node has children $=3 (N)$, and each parent-child relation is weighted, so it looks as a weighted unidirectional graph, with direction from root to leaves, like below:

I need to define this tree as a set of series in math notation and then I need to express the optimal series with maximum sum, especially when the tree could have a higher value for depth and children.
For example, in the above tree we have $13$ nodes in total from which we can constitute $9 (N$ x $M)$ series:
1: (0,1,4)
2: (0,1,5)
3: (0,1,6)
4: (0,2,7)
5: (0,2,8)
6: (0,2,9)
7: (0,3,10)
8: (0,3,11)
9: (0,3,12)

The optimal series is $(0, 3, 11)$ because the sum $= 1.2$
I tried to describe it as a set of series, but I'm not sure if it's correct:
$$
T=\left\{\left(p_i\left(q_j\right)_j^m\right)_i^{n^m}:i,j,n,m\in\mathbb{N}\right\}
$$
and then I tried to express the optimal series from that set as:
$$
max{\left[T\right]}=  (0, 3, 11)
$$
I'm not a mathematician, please kindly advise if something is wrong.
 A: A possibility would be to use weighted automata. Let me first explain this definition on your example. The picture is almost the same as yours,
except that this is now a directed graph. The vertical bars are just separators. The alphabet $A = \{a, b, c\}$ is used to encode the edges of your tree. Thus every path from the root to a leaf is encoded by a word of length $2$. For instance, the path from $0$ to $10$ is encoded by the word $ca$.

The weight of an edge is the number in red. For instance, the weight of the edge $1 \xrightarrow{\color{blue}{c}\mid\color{red}{0.6}} 6$ is $0.6$. The weight of a path is obtained by summing the weights of its edges. Actually, since every word $u$ of length $2$ defines a unique path of origin $0$, its weight $w(u)$ is well defined. For instance, $w(ca) = 0.3 + 0.5 = 0.8$.
Thus the optimal weight is
$$
\max\{ w(u) \mid u \in A^2\}
$$
For a $N$-ary tree of depth $M$, you would use the alphabet $A = \{a_1, a_2, \ldots, a_N\}$ instead and words of length $M$, so the optimal weight would be
$$
\max\{ w(u) \mid u \in A^M\}
$$
The optimal word would be a word of maximal weight.
