public Trie optimize(Trie orig) {List<CharSequence> cmds = orig.cmds;List<Row> rows = new ArrayList<>();List<Row> orows = orig.rows;int remap[] = new int[orows.size()];for (int j = orows.size() - 1; j >= 0; j--) {liftUp(orows.get(j), orows);}Arrays.fill(remap, -1);rows = removeGaps(orig.root, orows, new ArrayList<Row>(), remap);return new Trie(orig.forward, remap[orig.root], cmds, rows);}

public override Trie Optimize(Trie orig){IList<string> cmds = orig.cmds;IList<Row> rows = new List<Row>();IList<Row> orows = orig.rows;int[] remap = new int[orows.Count];for (int j = orows.Count - 1; j >= 0; j--){LiftUp(orows[j], orows);}Arrays.Fill(remap, -1);rows = RemoveGaps(orig.root, orows, new List<Row>(), remap);return new Trie(orig.forward, remap[orig.root], cmds, rows);}
