I did try that at one point, but this will cause the iteration to trigger for dictionaries (because they are iterable), and I don't want to iterate over dictionaries; just sets and lists. You are right, though, that there may be a cleaner way to achieve the goal.