Optimal broadcasting in treelike graphs