var TreeHtmlGroup = (function () {
var tree = document.querySelector('ul')
var group_id = 0
var tree_id_prefix = 0
function group_by_key(ul, key_func) {
var last_key = null
var lis_groups = []
function last_group() {
return lis_groups[lis_groups.length - 1]
}
var children_count = ul.children.length
for (var i = 0; i < children_count; i++) {
var li = ul.children[i]
callee_path = key_func(li)
if (last_key !== callee_path) {
last_key = callee_path
lis_groups.push([])
}
last_group().push(li)
}
if (lis_groups.length == 1 && key_func(lis_groups[0][0]) == key_func(ul.parentElement)) {
return
}
lis_groups.forEach(function (group) {
var key = key_func(group[0])
wrap_into_group(group, key)
})
}
function wrap_into_group(lis, key) {
var id = 'g' + group_id++
var html = '