title: Algorithm to detect when graph re-converges (similar to common subtree?)
body: <p>I've been working on this problem all day, I'm re-writing one of our legacy products and I'm having a hard time determining how to find a specific node in my flow chart.  The problem reminds me of University, but for the life of me I can't come up with an algorithm to solve this.</p>
  
  <p>I've attached 3 screen shots to help explain this, but the basic problem is, given a YES/NO? decision node, locate the closest child node that terminates the branch.  </p>
  
  <p>I'm working in C# .NET and JSON.  In JSON I've got an object that gives each node a unique identifier, and also identifies each "link" from one node to the next.  I would hope to write a function (or several) to determine the first "end node" given a branched node in C#.  Currently I've built out the jSON into XML in C#.</p>
  
  <p>Any and all ideas encouraged, not really looking for code but an approach/algorithm.  </p>
  
  <p><img src="https://i.stack.imgur.com/frNUZ.jpg" alt="enter image description here">
  <img src="https://i.stack.imgur.com/tW1jg.jpg" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/tcjEj.jpg" alt="given the yes/no find the delay block.. first node that all child nodes traverse to"></p>
  
  <p>Attached is the output in jSON from the diagram:</p>
  
  <pre><code>{ "class": "go.GraphLinksModel",
    "linkFromPortIdProperty": "fromPort",
    "linkToPortIdProperty": "toPort",
    "nodeDataArray": [ 
  {"key":-1, "category":"Start", "loc":"169 288", "text":"Start"},
  {"key":-2, "category":"End", "loc":"855 394", "text":"End"},
  {"category":"Branch", "text":"Yes or No", "key":-4, "loc":"284.8837209302326 285.7848837209302"},
  {"category":"DelayNode", "text":"Delay", "key":-3, "loc":"365.8837209302326 215.52345997177622"},
  {"category":"Branch", "text":"Yes or No", "key":-5, "loc":"478.8837209302326 214.52345997177622"},
  {"category":"DelayNode", "text":"Delay", "key":-6, "loc":"568.8837209302326 151.52345997177622"},
  {"category":"DelayNode", "text":"Delay", "key":-7, "loc":"573.8837209302326 268.5234599717762"},
  {"category":"DelayNode", "text":"Delay", "key":-8, "loc":"653.8837209302326 215.52345997177622"},
  {"category":"Branch", "text":"Yes or No", "key":-9, "loc":"392.8837209302326 392.5234599717762"},
  {"category":"DelayNode", "text":"Delay", "key":-10, "loc":"454.8837209302326 317.5234599717762"},
  {"category":"DelayNode", "text":"Delay", "key":-11, "loc":"550.8837209302326 473.5234599717762"},
  {"category":"DelayNode", "text":"Delay", "key":-12, "loc":"549.8837209302326 317.5234599717762"},
  {"category":"DelayNode", "text":"Delay", "key":-13, "loc":"711.8837209302326 343.5234599717762"},
  {"category":"Branch", "text":"Yes or No", "key":-14, "loc":"434.8837209302326 487.5234599717762"}
   ],
    "linkDataArray": [ 
  {"from":-4, "to":-3, "fromPort":"T", "toPort":"L", "visible":true},
  {"from":-1, "to":-4, "fromPort":"R", "toPort":"L"},
  {"from":-3, "to":-5, "fromPort":"R", "toPort":"L"},
  {"from":-5, "to":-6, "fromPort":"T", "toPort":"L", "visible":true},
  {"from":-5, "to":-7, "fromPort":"B", "toPort":"L", "visible":true, "text":"NO"},
  {"from":-6, "to":-8, "fromPort":"R", "toPort":"L"},
  {"from":-7, "to":-8, "fromPort":"R", "toPort":"L"},
  {"from":-4, "to":-9, "fromPort":"B", "toPort":"L", "visible":true, "text":"NO"},
  {"from":-9, "to":-10, "fromPort":"T", "toPort":"L", "visible":true},
  {"from":-10, "to":-12, "fromPort":"R", "toPort":"L"},
  {"from":-11, "to":-13, "fromPort":"R", "toPort":"L"},
  {"from":-12, "to":-13, "fromPort":"R", "toPort":"L"},
  {"from":-8, "to":-13, "fromPort":"R", "toPort":"L"},
  {"from":-13, "to":-2, "fromPort":"R", "toPort":"L"},
  {"from":-9, "to":-14, "fromPort":"B", "toPort":"L", "visible":true, "text":"NO"},
  {"from":-14, "to":-11, "fromPort":"T", "toPort":"L", "visible":true},
  {"from":-14, "to":-11, "fromPort":"B", "toPort":"L", "visible":true, "text":"NO"}
   ]}
  </code></pre>