Checking for Invalid Key
<p>I have a while loop:</p>

<pre><code>while parent != None:
     pathList.append(parentMap[parent])
     parent = parentMap[parent]
</code></pre>

<p>What I want to do with this list is simply add the parent value (already determined in other parts of the code) of a parent value to a list until I've reached the top of a tree and there are no more parents remaining. The while loop operates under the idea that once parentMap[parent] is provided with an invalid [parent] key, it will be assigned the value of "None" and the loop will terminate. This doesn't happen. Instead, once I get to the topmost key, (5, 5), the program throws an error stating "invalid key." Thoughts? </p>
