I am new to Python. I am trying to build a rule where if two conditions are met the program would generate a variable, but for some reason `if` statements of this rule are not running.

Let me explain the context of what I am doing: I have the following lists and a function that returns any elements matching any 2 given lists, dictionaries, strings, etc.:

```
poa_term_variations = ['power of attorney', 'poa']
poa_corporate_identifier = ["to attend any partners’ meeting", 'to represent the grantor regarding any change or amendment to the articles of association', "to subscribe for new quotas of the company's capital"]
poa_cnpj_identifier = ['brazilian federal revenue office', 'basic cnpj entry document']

#text variable is actually information from a .txt file in my code, which I converted into a list just like below. 
text = ['da#897-0095-v4',
 'd#30/04/2019',
 'h#2.0',
 'power of attorney',
 '(a) to represent the grantor in its capacity of partner of the limited
 liability company hk co., with head office in xxxxx, enrolled with the 
general taxpayers registry (cnpj/mf) under no. xxxxx and with the registry of 
companies under no. xxxxx (hereinafter referred to as company); (b) to attend any 
partners meeting of the company and vote the quotas of the grantor 
as instructed by the grantor, by email sent from mr. [complete name], in relation 
to any matter submitted to the appreciation of the partners, including, but not limited 
to, the approval of financial statements and election of managers, officers
 and/or directors; (c) to represent the grantor regarding any change or amendment 
to the articles of association approved by the grantor; (d) to subscribe for new quotas of the company\'s capital approved by the grantor']

#this function verifies if a certain term inside a list is also located in another list
def term_tracker(document, term_variations):
    terms = []         

    #If term_variations is a list
    if isinstance(term_variations, list) == True:
        for term in term_variations:
            #If we find a term in the document, append that term to a list
            if any([str(term) in i for i in document]):
                terms.append(term)

    #If term_variations is a string, find that string in all documents
    elif isinstance(term_variations, str) == True:
        if any([term_variations in i for i in document]) == True:
            terms.append(term_variations)

    return terms

```

For some reason, whenever I try to pass the following chunk of code, the first `elif` statement does not run:

```
for string in text:
        if len(term_tracker(text[0:4], poa_term_variations)) > 0:
            print('Found PoA type')
            document_type = term_tracker(text, poa_term_variations)

            if len(term_tracker(text, poa_corporate_identifier)) > 0:
                if len(term_tracker(text, poa_cnpj_identifier)) > 0:
                    document_nature = 'granting powers for corporate representation and representation before the Federal Revenue Office'
                    print('Found PoA Corporate/CNPJ type')
                    break

            #THIS IS THE STATEMENT THAT SHOULD RUN AND IT IS NOT RUNNING                                                                
            elif len(term_tracker(text, poa_corporate_identifier)) > 0:
                if len(term_tracker(text, poa_cnpj_identifier)) == 0:
                    document_nature = 'granting powers for corporate representation'
                    print('Found PoA Corporate type')
                    break

            elif len(term_tracker(text, poa_cnpj_identifier)) > 0:
                print('ok1')
                if len(term_tracker(text, poa_corporate_identifier)) == 0:
                    print('ok2') 
                    document_nature = 'granting powers for representation before the Federal Revenue Office'
                    print('Found PoA CNPJ type')             

            work_summary = ['Work description: ' + 'Drafting PoA for the purposes of ' + str(document_nature) + '.']

```

I know that the first `if` statement runs because `print('Found PoA type')` runs. However, the first `elif` statement should also run as (i) 
 `poa_corporate_identifier` list contains at least one term matching in `text` variable, and (ii) `poa_cnpj_identifier` does not have any term matching in `text` variable. This is the error I get: 

```
>>> work_summary = ['Work description: ' + 'Drafting PoA for the purposes of ' + str(document_nature) + '.']
>>> NameError: name 'document_nature' is not defined 

```

Note that other sample documents I am using to test my code and that match the conditions in the second `if` statement and the second `elif` statement run properly. 

Already tried other comparison operators (`!=`, `<=`, `is not`, etc.), but no success.

How can I solve this issue?