addItemToList = function(item, depth) {
      if (item.inList) {
        return;
      }
      item.treeClasses = 'depth-' + depth;
      if (item.extension) {
        item.treeClasses += ' extension';
        depth--; // For the children
      }
      item.inList = true;
      newList.push(item);
      if (item.children) {
        item.children.forEach(function(child) {
          addItemToList(child, depth + 1);
        });
      }
      if (item.extends) {
        var parent = self.itemsByName[item.base.name];
        if (parent != null) {
          addItemToList(parent, depth + 1);
        }
      }
    }
Organize items according to class & inheritance, note every item's depth,
and add file name items to the list.

@param list The list of items
@return {Array} A modified, reorganized list