code: function getMindMapDimensions(root) {
      var pos = root.getPosition();
      var left = 0, top = 0, right = 0, bottom = 0;
      var padding = 50;
  
      function checkDimensions(node) {
        var pos = node.getPosition();
        var tm = node.textMetrics;
  
        if (pos.x < left) {
          left = pos.x;
        }
  
        if (pos.x + tm.width > right) {
          right = pos.x + tm.width;
        }
  
        if (pos.y < top) {
          top = pos.y;
        }
  
        if (pos.y + node.outerHeight() > bottom) {
          bottom = pos.y + node.outerHeight();
        }
      }
  
      checkDimensions(root);
      root.forEachDescendant(function(node) {
        checkDimensions(node);
      });
  
      // find the longest offset to either side and use twice the length for
      // canvas width
      var horizontal = Math.max(Math.abs(right), Math.abs(left));
      var vertical = Math.max(Math.abs(bottom), Math.abs(top));
  
      return {
        width : 2 * horizontal + padding,
        height : 2 * vertical + padding
      };
    }
docs: Finds the nodes which are farthest away from the root and calculates the
  actual dimensions of the mind map.
  
  @param {mindmaps.Node} root
  @returns {object} with properties width and height