title: Nested Dictionary Iteration in Python
body: <p>I have a dictionary that has a few options key value pairs and then a sub_dict attribute that is a list of more dictionaries with the same attributes and these also have the potential to have sub_dicts all the way down. </p>
  
  <p>In python I break it apart and work on them individually and change them one at a time and want to recombine the changed system with the whole one. I am not sure how to iterate through it though.</p>
  
  <pre><code>{base_system: {
  name: "root",
  description: "data dictionary",
  common_data: {},
  other_data: {},
  more_data: {},
  sub_systems: [
      {
          base_system: {
          name: "another system",
          description: "inherits from top level",
          sub_systems: [
              {
                  base_system: {}
              },
              {
                  base_system: {}
              }
          ]
          }
      },
      {
          base_system: {
              name: "one more system",
              description: "inheriting again",
              sub_systems: [
              {
                  base_system: {
                  name: "child system",
                  description: "no kids here",
                  other_data: {},
                  more_data: {}
                  }
              },
              {
                  base_system: {
                  name: "kid system",
                  description: "no children here"
                  }
              }
              ]
          }
      }
  ]
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I want to do something like this but I'm not sure what to do to make it recursive.</p>
  
  <pre><code>#Have some recursive function to dig through the overall dictionary then test:
  if the_dict_object["space_system"]["name"] == changed_json_system["space_system"]["name"]:
    #then when it passes that if statement I can just set
    the_dict_object = changed_json_system
  </code></pre>
  
  <p>But I am not sure how to iterate through the nested dictionary and still have a hold of the overall object.</p>