title: python mongodb distinct key return whole sub document
body: <p>I have a further question based on this <a href="https://stackoverflow.com/questions/16155266/mongodb-how-to-get-distinct-list-of-sub-document-field-values">question</a>,</p>
  
  <pre><code>{
     "family": "Smith",
     "children": [
          {
              "child_name": "John",
              "age":5
          },
          {
              "child_name": "Anna",
              "age":6
          },
      ]
  }
  
  {
     "family": "Williams",
     "children": [
          {
              "child_name": "Anna",
              "age":6
          },
          {
              "child_name": "Kevin",
              "age":7
          },
      ]
  }
  </code></pre>
  
  <p>As the highest voted answer shows, I can get the distinct child name by the following code,</p>
  
  <pre><code>  db.collection.distinct("children.child_name");
  </code></pre>
  
  <p>My question is how can I get the whole sub document for each distinct child name?</p>
  
  <p>That means I would like to have returned a list of sub-document based on unique child name,</p>
  
  <pre><code>[ {"child_name":"John", "age":5}, {"child_name": "Anna","age":6}, {"child_name":"Kevin","age":7}]
  </code></pre>