_.tree is an extension for underscore.js, which converts flat Collections into tree structures.
Take the following collection. Each item in the collection has an id and a parent_id, describing how it relates to other items.
var input = [
{ id: 1, name: 'Grandfather', parent_id: 0 },