title: Restkit Many-To-Many Relation causes duplicated objects
body: <p>I am using RestKit release/0.10.0 branch for my application. I'm using CoreData and RestKit's object mapping feature to load/synchronize data. The XML data I am loading looks as follows (simplified):</p>
  
  <pre><code>&lt;iphoneSync&gt;
  &lt;time&gt;12-04-03 16:47&lt;/time&gt;
  &lt;pages&gt;
      &lt;page id="177"&gt;
          &lt;title&gt;
              Foo
          &lt;/title&gt;
          &lt;meta&gt;
              &lt;tags&gt;
                  &lt;tag type="undef" id="16"&gt;Lorem&lt;/tag&gt;
                  &lt;tag type="undef" id="20"&gt;Ipsum&lt;/tag&gt;
              &lt;/tags&gt;
          &lt;/meta&gt;         
      &lt;/page&gt;
      &lt;page id="580"&gt;
          &lt;title&gt;
              Bar
          &lt;/title&gt;
          &lt;meta&gt;
              &lt;tags&gt;
                  &lt;tag type="undef" id="16"&gt;Lorem&lt;/tag&gt;
                  &lt;tag type="undef" id="20"&gt;Ipsum&lt;/tag&gt;
                  &lt;tag type="" id="46"&gt;Abc&lt;/tag&gt;
                  &lt;tag type="symptom" id="47"&gt;Cde&lt;/tag&gt;
              &lt;/tags&gt;
          &lt;/meta&gt;
      &lt;/page&gt;
  &lt;/pages&gt;
  </code></pre>
  
  <p></p>
  
  <p>The domain classes <strong>Page</strong> and <strong>Tag</strong> look as follows:</p>
  
  <pre><code>@interface Page : NSManagedObject
  @property (nonatomic, strong) NSNumber * id;
  @property (nonatomic, strong) NSString * title;
  @property (nonatomic, strong) NSSet *tags;
  @end
  
  @interface Tag : NSManagedObject
  @property (nonatomic, strong) NSNumber * id;
  @property (nonatomic, strong) NSString * name;
  @property (nonatomic, strong) NSString * type;
  @property (nonatomic, strong) NSSet *pages;
  @end
  </code></pre>
  
  <p>The Page entity has many tags and a Tag can belong to multiple pages. So I have set the relationship from both sides to be To-many. The delete rule from Page to tags is cascade. From Tag to Pages it's nullify.</p>
  
  <p><img src="https://i.stack.imgur.com/crPO8.png" alt="CoreData properties"></p>
  
  <p>The mapping setup:</p>
  
  <pre><code>//Tag mapping
  RKManagedObjectMapping* tagMapping = [RKManagedObjectMapping mappingForClass:[Tag class] inManagedObjectStore:[RKManagedObjectStore defaultObjectStore]];
  tagMapping.setDefaultValueForMissingAttributes = YES;
  tagMapping.primaryKeyAttribute = @"id";
  [tagMapping mapKeyPathsToAttributes:@"type",@"type",@"text",@"name",@"id",@"id", nil];
  
  //Page mapping
  RKManagedObjectMapping* pageMapping = [RKManagedObjectMapping mappingForClass:[Page class] inManagedObjectStore:[RKManagedObjectStore defaultObjectStore]];    
  pageMapping.primaryKeyAttribute = @"id";
  [pageMapping mapKeyPathsToAttributes:@"id",@"id",@"title",@"title",nil];
  [pageMapping mapKeyPath:@"meta.tags.tag" toRelationship:@"tags"  withMapping:tagMapping];
  pageMapping.setNilForMissingRelationships = YES;
  pageMapping.setDefaultValueForMissingAttributes = YES;
  
  //Root mapping
  RKObjectMapping* rootMapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
  [rootMapping mapKeyPath:@"iphoneSync.pages.page" toRelationship:@"pages" withMapping:pageMapping];
  
  //RKObjectManager
  RKManagedObjectStore* mainManagedObjectStore = [RKManagedObjectStore objectStoreWithStoreFilename:OBJECT_STORE_FILE];
  RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:baseURL];
  [RKObjectManager setSharedManager:objectManager];
  objectManager.acceptMIMEType = RKMIMETypeXML;
  objectManager.serializationMIMEType = RKMIMETypeXML;
  objectManager.objectStore = mainManagedObjectStore;
  objectManager.objectStore.cacheStrategy = [RKInMemoryManagedObjectCache new];
  objectManager.client.cachePolicy = RKRequestCachePolicyNone;
  
  [objectManager.mappingProvider addObjectMapping:rootMapping];    
  [objectManager.mappingProvider addObjectMapping:pageMapping];
  [objectManager.mappingProvider addObjectMapping:tagMapping];
  </code></pre>
  
  <p>Then I load it like this:</p>
  
  <pre><code>[objectManager loadObjectsAtResourcePath:@"/" usingBlock:^(RKObjectLoader* loader) {
      loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[NSMutableDictionary class]];
  }];
  </code></pre>
  
  <p>The objects are loaded and mapped properly, but the tags with ID 16 and ID 20 are stored twice in the database (one for each page entity). But I want them to be distinct such that tags with the same ID are only stored once. What am I doing wrong?</p>