title: recursive function for extract elements from deep nested lists/tuples
body: <p>I want to write a function that extracts elements from deep nested tuples and lists, say I have something like this </p>
  
  <pre><code>l = ('THIS', [('THAT', ['a', 'b']), 'c', ('THAT', ['d', 'e', 'f'])])
  </code></pre>
  
  <p>And I want a flat list without 'THIS' and 'THAT':</p>
  
  <pre><code>list = ['a', 'b', 'c', 'd', 'e', 'f']
  </code></pre>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>def extract(List):
      global terms
      terms = []
      for i in word:
          if type(i) is not str:
              extract(i)
          else:
              if i is not "THIS" and i is not "THAT":
                  terms.append(i)
      return terms
  </code></pre>
  
  <p>But I keep getting <code>list = ['d', 'e', 'f']</code>, it looks like the <code>terms = []</code> is set again after looping to <code>'c'</code>. </p>