title: Ancestor Query for immediate parent
body: <p>I'm attempting to model a recursive structure with App Engine NDB:</p>
  
  <pre><code>class Root(ndb.Model):
      pass
  
  class Node(ndb.Model):
      #Node can have either a Root, or another Node as parent
      pass
  
  root_key = Key(Root, 1)
  node_a = Key(Root, 1, Node, 2)
  node_b = Key(Root, 1, Node, 3)
  node_a_a = Key(Root, 1, Node, 2, Node, 4)
  </code></pre>
  
  <p>From here, I want to query the Root entity for immediate children. What I can do is to query for <em>all</em> descendants of the root:</p>
  
  <pre><code>Node.query(ancestor=root_key) # returns node_a, node_b, and node_a_a
  </code></pre>
  
  <p>What I'd like to do is:</p>
  
  <pre><code>Node.query(parent=root_key) # returns node_a, node_b
  </code></pre>
  
  <p>but it seems that querying by (immediate) parent key isn't supported by the ndb api. Hopefully I'm wrong. Looking forward to elucidation. Thanks</p>