Optimal estimation of Gaussian (poly)trees