replace dict comprehension in toposort for python 2.6