title: Filter a list of dictionaries in Python based on key
body: <p>I would need to filter a list of dictionaries to only retain dictionaries which have a key called "children". Here is an example of list:</p>
  
  <pre><code>[{u'id': 5650, u'children': [{u'id': 4635}]}, {u'id': 5648, u'children': [{u'id': 67}, {u'id': 77}]}, {u'id': 5649}]
  </code></pre>
  
  <p>And here is what I would need to obtain:</p>
  
  <pre><code>[{u'id': 5650, u'children': [{u'id': 4635}]}, {u'id': 5648, u'children': [{u'id': 67}, {u'id': 77}]}]
  </code></pre>
  
  <p>Here is what I have tried:</p>
  
  <pre><code>dict((k, data[k]) for k in keys if k in data)
  </code></pre>
  
  <p>And what I obtain, which is not good:</p>
  
  <pre><code>[{u'children': [{u'id': 4635}]}, {u'children': [{u'id': 67}, {u'id': 77}]}, {}]
  </code></pre>
  
  <p>Any clue?
  Thanks in advance!</p>