static L getBracketMap2(L tok, Map map, S openingBrackets, S closingBrackets) { map.clear(); new L stack; for (int i = 1; i < l(tok); i+= 2) { S t = tok.get(i); if (l(t) == 1) if (openingBrackets.contains(t)) stack.add(i); else if (closingBrackets.contains(tok.get(i))) map.put(empty(stack) ? 0 : liftLast(stack), i); } ret stack; }