eliminate duplicates in topo-sort