Utility function to sort tree by specific property or an array of properties
@param {array} tree The tree structure to sort
@param {array|string} propertyName Property names to sort the tree
@return {array} An array sorted by propertyName
969274
function sortBy(tree, propertyName) {
    var _this = this;

    // It is needed an array structure to sort.
    if (!_.isArray(tree)) tree = [tree];
    tree.forEach(function (item) {
      return _(item).keys().forEach(function (key) {
        if (_.isArray(item[key])) item[key] = _this.sortBy(item[key], propertyName);
      });
    });
    return _.sortBy(tree, propertyName);
  }
67727
function(sPropertyName) {
			var oResult = null;
			for (var i = -1, oCurrentSorter; (oCurrentSorter = this._aSortCondition[++i]) !== undefined;) {
				if (oCurrentSorter.property.name === sPropertyName) {
					oResult = {
						sorter : oCurrentSorter,
						index : i
					};
					break;
				}
			}
			return oResult;
		}
374174
function (node, name) {
    var propertyInfo = DOMProperty_1.getPropertyInfo(name);
    if (propertyInfo) {
      var mutationMethod = propertyInfo.mutationMethod;
      if (mutationMethod) {
        mutationMethod(node, undefined);
      } else if (propertyInfo.mustUseProperty) {
        var propName = propertyInfo.propertyName;
        if (propertyInfo.hasBooleanValue) {
          node[propName] = false;
        } else {
          node[propName] = '';
        }
      } else {
        node.removeAttribute(propertyInfo.attributeName);
      }
    } else {
      node.removeAttribute(name);
    }

    {
      ReactInstrumentation.debugTool.onHostOperation({
        instanceID: ReactDOMComponentTree_1.getInstanceFromNode(node)._debugID,
        type: 'remove attribute',
        payload: name
      });
    }
  }
1300022
function sort(object) {
    if (sortArrays === true && Array.isArray(object)) {
      return object.sort();
    } else if (typeof object !== "object" || object === null) {
      return object;
    }

    return Object.keys(object).sort().map(function(key) {
      return {
        key: key,
        value: sort(object[key])
      };
    });
  }
901619
function tree(root) {
	var structure = {};

	var _files = fs.readdirSync(root);
	for(var i=0; i<_files.length; i++) {
		if ((_files[i] !== '.') && (_files[i] !== '..')) {
			var stats = fs.statSync(root + '/' + _files[i]);
			if (stats.isDirectory()) {
				structure[_files[i]] = tree(root + '/' + _files[i]);
			} else if (stats.isFile() && xIsJsFile.test(_files[i])) {
				try {
					structure[_files[i]] = require(root + '/' + _files[i]);
				} catch(err) {
					console.log('Could not load task in: ' + _files[i]);
					console.error(err);
				}
			}
		}
	}

	return structure;
}
876796
function getTree(table, options) {

      if (table.isPanel) {
        table = table.getView();
      }

      function getDefOpts() {
        return {
          throwIfInvisible: false,
          allFields: false
        };
      }

      var isVisible = table.isVisible(true);
      options = tiaEJ.ctMisc.checkVisibilityAndFillOptions(isVisible, options, getDefOpts);
      var panel = tiaEJ.search.parentPanel(table);
      var root = panel.getRootNode();
      var res = [];

      function traverseSubTree(node, indent) {

        var fieldsToPrint = ['text', 'checked', 'id'];

        if (tia.debugMode) {
          fieldsToPrint = [
            'text',
            'checked',
            'id',
            'visible',
            'expanded',
            'leaf',
            'expandable',
            'index',
            'depth',
            'qtip',
            'qtitle',
            'cls'
          ];
        }

        if (options.allFields) {
          res.push(indent + tiaEJ.ctMisc.stringifyAllRecord(node, fieldsToPrint, true));
        } else {
          res.push(indent + tiaEJ.ctMisc.stringifyRecord(node, fieldsToPrint, true));
        }

        if (node.hasChildNodes()) {
          indent += tia.cC.content.indent;
          node.eachChild(function (curNode) {
            traverseSubTree(curNode, indent);
          });
        }
      }

      traverseSubTree(root, '');

      return tia.cC.content.wrap('Tree content: \n' + res.join('\n') + '\n');

    }
373699
function handleProperties(schema, properties, node, stack) {
    var name = handleTagName(schema, node.tagName, node, stack)
    var attrs = schema.attributes
    var props = properties || {}
    var result = {}
    var allowed
    var prop
    var value

    allowed = own.call(attrs, name) ? attrs[name] : []
    allowed = [].concat(allowed, attrs['*'])

    for (prop in props) {
        value = props[prop]

        if (
            allowed.indexOf(prop) === -1 &&
            !(data(prop) && allowed.indexOf('data*') !== -1)
        ) {
            continue
        }

        if (value && typeof value === 'object' && 'length' in value) {
            value = handlePropertyValues(schema, value, prop)
        } else {
            value = handlePropertyValue(schema, value, prop)
        }

        if (value !== null && value !== undefined) {
            result[prop] = value
        }
    }

    return result
}
98614
function createTree(){
    for (var i = 0; i < gRootNodes.length; ++i){
        var node = {
            _id : gRootNodes[i]._id, //todo : id instead of name?
            node : gRootNodes[i],
            parent : "root",
            childNodes : loadChildNodes(gRootNodes[i])
        };
        gTree.childNodes.push(node);
    }
}
1273662
function(tree) {
        var branches = tree.branches;
        for (var i in branches) {
          var subTree = branches[i];
          if (subTree.isOpen && !subTree.isLoading) {
            branches[i] = trimSubBranch(subTree);
          } else {
            branches[i] = {
              id: subTree.id,
            };
            if (subTree.label) {
              branches[i].label = subTree.label;
            }
          }
        }
        return tree;
      }
480758
function sortTasks(tasks, callback){
	async.waterfall([
		function(done){
			var availTasks = {};
			var tree = {};
			forEach(tasks, function(obj, key){
				obj.name = obj.name || obj.id || obj.identity || key || "unknown";
				obj.ext = (obj.ext && obj.ext.indexOf('.') != -1) ? obj.ext : ('.'+obj.ext);
				availTasks[obj.name] = obj;
				tree[obj.name] = (obj.runBefore) ? ( (isArray(obj.runBefore)) ? obj.runBefore : [obj.runBefore]) : [];
			});
			done(null, DepResolver(tree).map(function(name){ return availTasks[name]; }))
		}
	], callback);
}
5768
function tree() {
            var result = {
                name: 'root',
                children: []
            }

            function _parseChildren(parentClientId, children) {
                Util.each(CACHE, function(item) {
                    if (item.parentClientId === parentClientId) {
                        children.push({
                            name: item.moduleId + ',' + item.clientId,
                            module: item,
                            children: _parseChildren(item.clientId, [])
                        })
                    }
                })
                return children
            }

            _parseChildren(Constant.ROOT_CLIENT_ID, result.children)

            return result
        }
688184
function tree (list) {
  var mapped = {}
  for (var i = 0, item; i < list.length; i++) {
    item = list[i]
    if (!item || !item.id) continue
    mapped[item.id] = item
  }

  var result = []
  for (var ii = 0; ii < list.length; ii++) {
    item = list[ii]

    if (!item) continue
    /* jshint -W041 */
    if (item.pid == undefined && item.parentId == undefined) {
      result.push(item)
      continue
    }
    var parent = mapped[item.pid] || mapped[item.parentId]
    if (!parent) continue
    if (!parent.children) parent.children = []
    parent.children.push(item)
  }
  return result
}
570194
function getPropertyValue(node, path) {
  const parts = typeof path === 'string' ? path.split('.') : path;

  if (parts.length === 1) {
    return node[path];
  }

  const property = node[parts[0]];

  if (property && parts.length > 1) {
    parts.shift();
    return getPropertyValue(property, parts);
  }

  return property;
}
590273
function toArray(tree, f) {
	var out = [];
	if (tree.root) {
		_util.rootToArray(tree.root, f, out);
	}
	var tail = tree.tail;
	for(var i = 0, l = tail.length; i<l; i++) {
		out.push(f(tail[i]));
	}
	return out;
}
1039302
function(tree) {
            var maxRowDepth = 1;
            var currentRow;
            var currentColumn;

            // Calculate the max depth of descendants for this row
            var countMaxRowDepth = function(row, tmpRowDepth) {
                tmpRowDepth = tmpRowDepth || 1;

                for(var n=0; n<row.length; n++) {
                    var col = row[n];
                    // Column has children, so keep counting
                    if(YAHOO.lang.isArray(col.children)) {
                        tmpRowDepth++;
                        countMaxRowDepth(col.children, tmpRowDepth);
                        tmpRowDepth--;
                    }
                    // No children, is it the max depth?
                    else {
                        if(tmpRowDepth > maxRowDepth) {
                            maxRowDepth = tmpRowDepth;
                        }
                    }

                }
            };

            // Count max row depth for each row
            for(var m=0; m<tree.length; m++) {
                currentRow = tree[m];
                countMaxRowDepth(currentRow);

                // Assign the right ROWSPAN values to each Column in the row
                for(var p=0; p<currentRow.length; p++) {
                    currentColumn = currentRow[p];
                    if(!YAHOO.lang.isArray(currentColumn.children)) {
                        currentColumn._nRowspan = maxRowDepth;
                    }
                    else {
                        currentColumn._nRowspan = 1;
                    }
                }

                // Reset counter for next row
                maxRowDepth = 1;
            }
        }
652928
function getSortingPropertyName(property) {
  if (property.type === 'ExperimentalSpreadProperty') {
    return `...${property.argument.name}`;
  }

  if (property.key.type === 'Literal') {
    return property.key.value;
  }

  if (property.key.type === 'Identifier') {
    return `${property.key.name}`;
  }
}
23023
function arrayTreeFilter (data, filterFn, options) {
    options = options || {}
    options.childrenKeyName = options.childrenKeyName || 'children'
    let children = data || []
    const result = []
    let level = 0
    do {
        const foundItem = children.filter(function (item) {
            return filterFn(item, level)
        })[0]
        if (!foundItem) {
            break
        }
        result.push(foundItem)
        children = foundItem[options.childrenKeyName] || []
        level += 1
    } while (children.length > 0)
    return result
}