update tree matrix