def lex_balance
import qasim-bend-kit@0.1.0.2/libs/JSON.bend as JSONimport Base
1092def lex_balance(fuel: Nat, trees: List<&2, LexTree>) -> LexTree:
1093 match fuel:
1094 case 0n: lex_join(trees)
1095 case 1n+p:
1096 match trees:
1097 case Nil{}: LexEmpty{}
1098 case h <> Nil{}: h
1099 case a <> b <> t: lex_balance(p, lex_pairs(a <> b <> t))