this should be implemented using dict.items, see: https://gist.github.com/gidden/7174306