Convert Flat data structure to hierarchical data

http://stackoverflow.com/questions/10661887/how-to-make-a-tree-object-out-of-a-flat-tree 

http://stackoverflow.com/questions/3228334/how-to-display-flat-data-structure-into-hierarchical-data-structure-java 

http://ho.runcode.us/q/how-to-efficiently-build-a-tree-from-a-flat-structure 

http://stackoverflow.com/questions/920930/how-to-create-json-by-javascript-for-loop