@Override
 public void mergeWith(Record record, Map<Record, Object> recordsToRefresh) {
   super.mergeWith(record, recordsToRefresh);
   HierarchicalRecord hierarchicalRecord = (HierarchicalRecord) record;
   // parent ids
   for (HierarchicalRecord parentRecord : hierarchicalRecord.getParentRecords()) {
     if (!isParentOf(parentRecord) && !parentRecord.isRoot())
       getHierarchicalIndex().addRelationship(parentRecord, this);
   }
   // child ids
   for (HierarchicalRecord childRecord : hierarchicalRecord.getChildRecords()) {
     if (!isChildOf(childRecord)) getHierarchicalIndex().addRelationship(this, childRecord);
   }
 }
 @Override
 public void write(LineWriter textWriter) {
   super.write(textWriter);
   textWriter.writeLine(1); // version
   textWriter.writeLine(isRoot);
   if (parentIds != null) {
     textWriter.writeLine(parentIds.length);
     for (int parentId : parentIds) textWriter.writeLine(parentId);
   } else {
     textWriter.writeLine(0);
   }
   if (childIds != null) {
     textWriter.writeLine(childIds.length);
     for (int childId : childIds) textWriter.writeLine(childId);
   } else {
     textWriter.writeLine(0);
   }
 }