read-trees: refactor the unpack_trees() part