public Row merge(Row master, Row existing) {Iterator<Character> i = master.cells.keySet().iterator();Row n = new Row();for (; i.hasNext();) {Character ch = i.next();Cell a = master.cells.get(ch);Cell b = existing.cells.get(ch);Cell s = (b == null) ? new Cell(a) : merge(a, b);if (s == null) {return null;}n.cells.put(ch, s);}i = existing.cells.keySet().iterator();for (; i.hasNext();) {Character ch = i.next();if (master.at(ch) != null) {continue;}n.cells.put(ch, existing.at(ch));}return n;}
public Row Merge(Row master, Row existing){Row n = new Row();foreach (char ch in master.cells.Keys){master.cells.TryGetValue(ch, out Cell a);Cell s = !existing.cells.TryGetValue(ch, out Cell b) || (b == null) ? new Cell(a) : Merge(a, b);if (s == null){return null;}n.cells[ch] = s;}foreach (char ch in existing.cells.Keys){if (master.At(ch) != null){continue;}n.cells[ch] = existing.At(ch);}return n;}