switch to python 3

Also simplify the code, we don't care about which data structure we are dealing with, everything goes through iterators