Accelerated Algorithms for Labeling and Relabeling of Trees, with Applications to Distribution Problems