title: Find end node in directed graph
body: <p>I have many subgraphs like this one:</p>
  <pre><code>import networkx as nx
  G = nx.DiGraph()
  G.add_edges_from([(2,1),(3,1),(1,4)])
  nx.draw(G)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/xP0qr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xP0qr.png" alt="enter image description here" /></a></p>
  <p>I want to find all start and endnodes. So I use:</p>
  <pre><code>startnodes = [x for x in G.nodes() if G.out_degree(x)==1 and G.in_degree(x)==0]
  endnode = [x for x in G.nodes() if G.out_degree(x)==0 and G.in_degree(x)==1][0]
  print(startnodes, endnode)
  [2, 3] 4
  </code></pre>
  <p>But some of the subgraphs look like below, with 2 in degrees for end node. How can I find end node for this?</p>
  <pre><code>G.add_edges_from([(2,1),(3,1)]
  </code></pre>
  <p><a href="https://i.stack.imgur.com/x0220.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x0220.png" alt="enter image description here" /></a></p>