private static void writeDependencyNode(final IonWriter writer,
                                          final WriteContext context,
                                          final ReferenceNode node)
    throws IOException {
    context.dependencyNodeCollector.add(node, new ObjectCollector.Processor<IOException>() {
      @Override
      public void process(boolean isAdded, int objectId) throws IOException {
        writer.stepIn(IonType.STRUCT);
        writer.setFieldName(OBJECT_ID_FIELD);
        writer.writeInt(objectId);
        if (isAdded) {
          writer.setFieldName("_type");
          writer.writeString(ReferenceNode.class.getSimpleName());
          writeDependencyCommonFields(writer, node);
        }
        writer.stepOut();
      }
    });
  }
private static void writeDependencyNode(final IonWriter writer,
                                          final WriteContext context,
                                          final ReferenceNode node)