code: function(data) {
  			// parse basic info from the dom item
  			var item = {
  				link: data.id,
  				text: data.textContent || data.innerText,
  				parent: ''
  			};
  
  			// build type identifier
  			var level = data.tagName;
  			for (var i = 0; i < data.classList.length; i++) {
  				level += ',' + data.classList[i];
  			}
  
  			// here be dragons
  			var stacksize = stack.length;
  			if (stacksize === 0) {
  				// we are at the top level and will stay there
  				stack.push(level);
  			} else if (level !== stack[stacksize - 1]) {
  				// traverse the ancestry, looking for a match
  				for (var j = stacksize - 1; j >= 0; j--) {
  					if (level == stack[j]) {
  						break; // found an ancestor
  					}
  				}
  				if (j < 0) {
  					// this is a new submenu item, lets push the stack
  					stack.push(level);
  					item.push = true;
  					parentstack.push(lastitem);
  				} else {
  					// we are either a sibling or higher up the tree,
  					// lets pop the stack if needed
  					item.pop = stacksize - 1 - j;
  					while (stack.length > j + 1) {
  						stack.pop();
  						parentstack.pop();
  					}
  				}
  			}
  
  			// if we have a parent, lets record it
  			if(parentstack.length > 0) {
  				item.parent= parentstack[parentstack.length-1];
  			}
  
  			// for next iteration
  			lastitem= item.link;
  			return item;
  		}
docs: used to build the tree