function expand(strings, {merge = true} = {}) {
const str = strings.slice().sort();
const walk = (p = "", o, i0, i1) => {
const children = [];
for(let i = i0, c; i < i1; i++) {
c = str[i]?.[o];
if(i + 1 < i1 && c === str[i + 1]?.[o]) continue;
if(i + 1 === i1 && c === undefined) continue;
children.push(walk(c, o + 1, i0, i + 1));
i0 = i + 1;
}
if(children.length === 1 && merge) return [p + children[0][0], children[0][1]];
return [p, children];
};
return walk("", 0, 0, str.length);
}