From trees to barcodes and back again: theoretical and statistical perspectives