title: Iteratively join dataset with the resulting dataset
body: <p>I am trying to find Circular Path, in a dataframe with 2 columns</p>
  
  <p>Eg:</p>
  
  <pre><code>Col1 Col2 
  A    B 
  C    A 
  B    D 
  D    C
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/IMf7U.png" rel="nofollow noreferrer">Table</a></p>
  
  <p>So, A-B-D-C-A is a circular route</p>
  
  <pre><code>df &lt;- sqldf("Select * from circuit as 'A' INNER JOIN circuit as 'B' ON A.'To'= B.'FROM'")
  result &lt;- df[df$`FROM`==df$`TO..4`,]
  </code></pre>
  
  <p>This gives me all the bidirectional routes, is there a way I can perform the join iteratively and find all possible circular routes?</p>