title: Expanding a fancyTree via lazy load
body: <p>I have set up my fancytree to open via lazy loading, and it works very nicely.</p>
  
  <pre><code>$("#tree").fancytree({
          selectMode: 1, quicksearch:true, minExpandLevel:2,
          autoScroll: true,
          source: [{
              title: "Root",
              key: "1",
              lazy: true,
              folder: true
          }],
          lazyLoad: function(event, data) {
              var node = data.node;
              data.result = {
                  url: "getTreeData.jsp?parent=" + node.key,
                  data: {
                      mode: "children",
                      parent: node.key
                  },
                  cache: false
              };
          }
  
  
      });
  </code></pre>
  
  <p>However, if a user has previously selected a point on the tree, I would like the tree to open to that point.
  I have a variable called hierarchy which looks like "1/5/10/11/200" and holds the sequence of keys to that certain point.</p>
  
  <p>The following will <strong>not</strong> work:</p>
  
  <pre><code>$("#tree").fancytree("getTree").getNodeByKey("1").setExpanded();
  $("#tree").fancytree("getTree").getNodeByKey("5").setExpanded();
  $("#tree").fancytree("getTree").getNodeByKey("10").setExpanded();
  $("#tree").fancytree("getTree").getNodeByKey("11").setExpanded();
  $("#tree").fancytree("getTree").getNodeByKey("200").setExpanded();
  </code></pre>
  
  <p>The reason why it will not work, apparently, is because there needs to be some delay between one statement and the next. </p>
  
  <p>The following code works, however it is in my mind messy:</p>
  
  <pre><code>function openNode(item) {
  
     $("#tree").fancytree("getTree").getNodeByKey(String(item)).setExpanded();
  }
  
  function expandTree(hierarchy) {
    var i=0;
    hierarchy.split("/").forEach(function (item) {
    if (item!="") {
       i++;
       window.setTimeout(openNode, i*100,item);
    }
  });
  </code></pre>
  
  <p>Is there any neater way of opening to a specific point on the tree?</p>