After spending some time trying to solve this problem, I ended up looking at the solution. Turns out the official solution calls for 2 matrices, one called table and one called smalltrees.
Why would you make a smalltrees matrix, its whole purpose being to count the number of ways to create a tree of height-2, when you can look it up on the main table matrix?