code: function depth(root) {
  	let i = 0;
  	let walker = document.createTreeWalker(root, 0xFFFFFFFF, {
  		acceptNode: function(node){
  			let nt = node.nodeType;
  			return nt === 1 || nt === 3;
  		}
  	});
  
  	while(walker.nextNode()) {
  		i++;
  	}
  	return i;
  }
docs: Get the depth of a Node