code: function isLeaf(obj) {
              if (angular.isUndefined(obj)) {
                  return false;
              }
  
              if (angular.isArray(obj)) {
                  return false;
              }
  
              if (!angular.isObject(obj)) {
                  return true;
              }
  
              if (obj.isLeaf) {
                  return true;
              }
  
              var isLeaf = false;
              var keys = Object.keys(obj);
              for (var i = 0, len = keys.length; i < len; i++) {
                  var property = keys[i];
                  if (property.charAt(0) === '$') {
                      continue;
                  }
  
                  if (!angular.isArray(obj[property]) && !angular.isObject(obj[property])) {
                      isLeaf = true;
                      break;
                  }
              }
  
              return isLeaf;
          }
docs: Check if an object is a leaf object.
  A leaf object is an object that contains the `isLeaf` property or that has property that are anything else
  than object or arrays.
  
  @param  {*}       obj The object to check if it's a leaf
  @return {boolean} If the object is a leaf object.