title: Looping through tree hierarchy in python?
body: <p>I'm new here and pretty new to python!</p>
  
  <p>We got a homework, and I already was able to do rest of it, but one problem remains:
  If I have a tree hierarchy like this:</p>
  
  <pre><code>root = [
      parent1 = [
          child1,
          child2 = [
              sub_child
          ]
          child3
      ],
      parent2 = [
          child1,
          child2
      ]
  ]
  </code></pre>
  
  <p>And they are all instances of one class named <code>TreeHierarchyClass</code>, and they all have a name attribute, how can I find the one with name I input?</p>
  
  <p>I tried to use for loops but there's no way to know how many I need? Getting the name is easy:</p>
  
  <pre><code>name = input("Enter name: ")
  if name == TreeHierarchyObject.name:
      print("Found it!")
  </code></pre>
  
  <p>but how do I loop through the objects?</p>