title: Keep track of depth in the object
body: <p>I have the following piece of code as an example:</p>
  
  <pre><code>var someObject = {
      id:'a',
      l1:{
          id:'b',
          l2:null
      }
  };
  
  var pointer = someObject;
  // seq = abc
  function doSomething(seq) {
      while() {
          Step 1: seq.charAt(0) is a === l0.id, therefore pointer =  someObject.l1;
          Step 2: seq.charAt(1) is b === l1.id, therefore pointer =  pointer.l2;
          Step 3: seq.charAt(2) is c !== l2.id, therefore:
              pointer = { id: c, l3:null}
      }
  }
  </code></pre>
  
  <p>After doSomething runs on <code>abc</code>, I want <code>someObject</code> to look like:</p>
  
  <pre><code>var someObject = {
      id:'a',
      l1:{
          id:'b',
          l2:{
              id:'c',
              l3:null
          }
      }
  };
  </code></pre>
  
  <p>So the question is, how do I keep track of where in <code>someObject</code> I am, in the most efficient way? Or is it actually possible at all to keep track of the <code>pointer</code>?</p>
  
  <p>Edit: In pure Javascript or even angular is fine. No jQuery please :)</p>