title: neo4j cypher query for hierarchical relationship matching
body: <p>I'm modeling a set of nodes which has some hierarchical relationships (as a PARENT relationship) but additionally some non-hierarchical relationship.</p>
  
  <p>Let's say it's a family tree with relationships to the birth country for each person, for simplicity</p>
  
  <p>So each birth country is a node and each person is a node, and I might create the relationship in cypher as:</p>
  
  <pre><code>start parent=node(123), child=node(456)
  create parent-[:PARENT]-&gt;child;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>start person=node(123), country=node(789)
  create person-[:BORN_IN]-&gt;country;
  </code></pre>
  
  <p>what I'd like to do is, for example, get a list of folks who don't have any ancestors from England, or folks who do have an ancestor from Japan, or the like.  I feel like this should be a reasonable query, but I am new to cypher and haven't a clue how to construct it. </p>
  
  <p><em><strong></em> UPDATE **</strong>
  After more extensive testing of cases, I've found that the query doesn't work exactly right in some.  Given a child with one parent from England and a grandparent not from England, a query for children without any ancestors from England incorrectly returns the child with a parent from England.  It looks like the way I've written the query, I get a return for the grandparent having a NULL relationship to england.  My query is as follows:</p>
  
  <pre><code>START n=node(*), ancestor=node(123)
  MATCH n-[r:PARENT*]-&gt;o-[b?:BORN_IN]-&gt;ancestor
  WHERE b IS NULL 
  RETURN DISTINCT n;
  </code></pre>
  
  <p>If all the person's ancestors were born in the country in question, it works fine.  </p>