# collects tags from root node and all nodes reachable via item[attribute]=value edges, # including all "None" edges def evaluate_tree(self, item): result = self.tags if not self.leaf_node(): if item.has_key(self.attribute): # item[] values can't be None for value in item[self.attribute]: if self.value_map.has_key(value): result = result | self.value_map[value].evaluate_tree(item) if self.value_map.has_key(None): result = result | self.value_map[None].evaluate_tree(item) return result(Syntax highligher used: http://tohtml.com/python/)
Upd.: I've updated, adding a couple of comments. The bug can be found without making tricky assumptions. Everything what's necessary is already in the code.
Upd2.: Comments are unscreened, the bug is explained here: http://morfizm.livejournal.com/472705.html