RecordId head = RecordId.fromString(state.get("head").toString());
NodeState before = new SegmentNodeState(store, base);
NodeState after = new SegmentNodeState(store, head);
Journal parent = store.getJournal(state.get("parent").toString());
SegmentWriter writer = new SegmentWriter(store);
while (!parent.setHead(base, head)) {
RecordId newBase = parent.getHead();
NodeBuilder builder =
new SegmentNodeState(store, newBase).builder();
after.compareAgainstBaseState(before, new MergeDiff(builder));
RecordId newHead =
writer.writeNode(builder.getNodeState()).getRecordId();