toPhylo is a recursive function that gets as input the root of a transmission tree. In lines 2-4, the function checks if the current node has no children i.e., a leaf, in this case the corresponding phylogenetic tree is simply a phylogenetic tree with a single node. In line 5, all child nodes of the root are decreasingly sorted according to their infection times in order to place them in the right order for the recursive calls in the subsequent lines (see Figure 2b). The for-loop in the lines 8-12 grows a ladder-like mini-phylogenetic tree from left where the right node at each iteration points to the recursively reconstructed phylogenetic subtree, by calling toPhylo at line 9, on the current transmission subtree.