function countSubTreeDepth(scope) {
          if (!scope) {
            return 0;
          }
          var thisLevelDepth = 0,
              childNodes = scope.childNodes(),
              childNode,
              childDepth,
              i;
          if (!childNodes || childNodes.length === 0) {
            return 0;
          }
          for (i = childNodes.length - 1; i >= 0 ; i--) {
            childNode = childNodes[i],
            childDepth = 1 + countSubTreeDepth(childNode);
            thisLevelDepth = Math.max(thisLevelDepth, childDepth);
          }
          return thisLevelDepth;
        }
Returns the depth of the deepest subtree under this node
@param scope a TreeNodesController scope object
@returns Depth of all nodes *beneath* this node. If scope belongs to a leaf node, the
  result is 0 (it has no subtree).