Avoid dictionary changing size in for loop in py3k