finished tree-by-matrix