Using recursive function but what is my termination?
<p>I am trying to figure out how to terminate my recursive function. As you can see in this picture below:</p>

<p><img src="http://i.stack.imgur.com/c0Wkq.jpg" alt="enter image description here"></p>

<p><code>getEmpty[9]</code> will return:</p>

<pre><code>[6,10]
</code></pre>

<p>But I need it to return <code>[6,8,9,10,11]</code></p>

<p>Because I want all the empties as long as it shares an edge with a previous empty box.</p>

<p>How to I terminate this recursion? </p>

<p>Currently I have </p>

<pre><code>getEmpty(9)
        #my code here
        return empties;


empties = [6,10]
</code></pre>

<p>I added this:</p>

<pre><code>for cell in empties:

        if(getEmpty(cell) not in empties):
            empties = empties+getEmpty(cell)
</code></pre>

<p>at the end, but it gives me an infinite loop that prints out:</p>

<pre><code>[6,10]
[9]
</code></pre>

<p>non stop, how do I fix this?</p>
