code: function () {
              var that = this;
  
              return function () {
                  return this.then(function () {
                      if (this.visible('.jstree-closed')) {
                          this.click('.jstree-closed > .jstree-ocl');
                          // there's no clear way to check if the page was loading
                          // or was already in the DOM
                          return casper
                              .then(that.waitUntilAllAjaxCallsFinish())
                              .then(that.expandPageTree());
                      }
  
                      return casper.wait(1000)
                          .then(that.waitUntilAllAjaxCallsFinish());
                  });
              };
          }
docs: Recursively expands the page tree to operate on page nodes.
  
  @function expandPageTree
  @returns {Function}