In the small phylogeny problem we, are given a phylogenetic tree and gene orders of the extant species and our goal is to reconstruct all of the ancestral genomes so that the number of evolutionary operations is minimized. Algorithms for reconstructing evolutionary history from gene orders are usually based on repeatedly computing medians of genomes at neighbouring vertices of the tree. We propose a new, more general approach, based on an iterative local optimization procedure. In each step, we propose candidates for ancestral genomes and choose the best ones by dynamic programming. We have implemented our method and used it to reconstruct evolutionary history of 16 yeast mtDNAs and 13 Campanulaceae cpDNAs.