Fix MergeTrees func to accept nil as ancestor parameter