I have a tree with following configuration:
n is the number of different vertices v ($0 \lt v \le n$). Each vertice v have value Val(v). Same vertex will have same value. Each vertex vi always have a set of branch all vertex v $\le$ vi. The tree have deep d which is the number of step from root to every leaf.
The tree have cost C which is total all values in all leaf. Please look at this link and this for example. When we have n, set of vi, and d how to get C.
First notice that at each depth $1 < d \leq n$ and counting sequence $c_{n,d}$, where $c_{n,d}$ represents the number of the $v_n$s we have at depth $d$, we have
$$ c_n = 1, 1, 1, \ldots \\ c_{n-1} = 1,2,3, \ldots \\ c_{n-2} = 1,3,6, \ldots \\ c_1 = 1, \sum_{k = 0}^{n-1} c_{n-k,1}, \sum_{k = 0}^{n-1} c_{n-k,2}, \ldots . $$
Take a look at these numbers carfully.
They are in fact, the diagonal columns of pascal's triangle.
Thus, we have that $c_{k,d} = {d - 1 \choose n - k}$ and then the sum we are looking for is $$\sum_{k = 1}^n {d - 1 \choose n - k} Val(v_k).$$