 <pre><code>def find_price(self, name): if self.dictionary[name]["price"]: return self.dictionary[name]["price"] else: #assuming this is in a class...otherwise use global instead of self return self.find_price(dictionary[name]["child1"])*dictionary[name]["child1_quantity"] + find_price(self.dictionary[name]["child2"])*self.dictionary[name]["child2_quantity"]#.....etc </code></pre> <p>this also assumes that the top level object that you read the data into is a diction where the names also serve as keys in addition to their name fields.</p>