title: Recursively looping through an object to build a property list
body: <p>Situation: I have a large object containing multiple sub and sub-sub objects, with properties containing multiple datatypes. For our purposes, this object looks something like this:</p>
  
  <pre><code>var object = {
      aProperty: {
          aSetting1: 1,
          aSetting2: 2,
          aSetting3: 3,
          aSetting4: 4,
          aSetting5: 5
      },
      bProperty: {
          bSetting1: {
              bPropertySubSetting : true
          },
          bSetting2: "bString"
      },
      cProperty: {
          cSetting: "cString"
      }
  }
  </code></pre>
  
  <p>I need to loop through this object and build a list of the keys that shows the hierarchy, so the list ends up looking like this:</p>
  
  <pre><code>aProperty.aSetting1
  aProperty.aSetting2
  aProperty.aSetting3
  aProperty.aSetting4
  aProperty.aSetting5
  bProperty.bSetting1.bPropertySubSetting
  bProperty.bSetting2
  cProperty.cSetting
  </code></pre>
  
  <p>I've got this function, which does loop through the object and spit out the keys, but not hierarchically:</p>
  
  <pre><code>function iterate(obj) {
      for (var property in obj) {
          if (obj.hasOwnProperty(property)) {
              if (typeof obj[property] == "object") {
                  iterate(obj[property]);
              }
              else {
                  console.log(property + "   " + obj[property]);
              }
          }
      }
  }
  </code></pre>
  
  <p>Can somebody let me know how to do this? Here's a jsfiddle for you to mess with: <a href="http://jsfiddle.net/tbynA/" rel="noreferrer">http://jsfiddle.net/tbynA/</a></p>