We study the conditions under which the isometry of spaces with metrics generated by weights given on the edges of finite trees is equivalent to the isomorphism of these trees. Similar questions are studied for ultrametric spaces generated by labelings given on the vertices of trees. The obtained results generalized some facts previously known for phylogenetic trees and for Gurvich-Vyalyi monotone trees. Keywords and phrases. Monotone tree, equidistant tree, phylogenetic tree, planted tree, finite ultrametric space, isometry of ultrametric spaces, isomorphism of trees, star.