title: Parse nested XML file and get the value of previous tag in python
body: <p>I have a huge nested .xml file with a lots of entries. What I need is to find a previous value if I know the child ID.</p>
  <p>Extraction of my xml file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot;?&gt;
  &lt;nodes&gt;
      &lt;node&gt;
          &lt;node_id&gt;0x2D&lt;/node_id&gt;
          &lt;num_1&gt;11&lt;/num_1&gt;
          &lt;num_2&gt;905.908&lt;/num_2&gt;
          &lt;signs&gt;
              &lt;sign&gt;
                  &lt;sign_id&gt;30&lt;/sign_id&gt;
                  &lt;name&gt;INDEX_0&lt;/name&gt;
                  &lt;size_b&gt;842069&lt;/size_b&gt;
                  &lt;content&gt;
                      &lt;models&gt;
                          &lt;model&gt;1_x&lt;/model&gt;
                          &lt;model&gt;2_x&lt;/model&gt;
                          &lt;model&gt;3_x&lt;/model&gt;
                          &lt;model&gt;4_x&lt;/model&gt;
                      &lt;/models&gt;
                      &lt;images&gt;
                          &lt;image&gt;
                              &lt;value&gt;VALUE1&lt;/value&gt;
                              &lt;folder_ids&gt;
                                  &lt;folder_id&gt;012345678&lt;/folder_id&gt;
                              &lt;/folder_ids&gt;
                          &lt;/image&gt;
                          &lt;image&gt;
                              &lt;value&gt;VALUE2&lt;/value&gt;
                              &lt;folder_ids&gt;
                                  &lt;folder_id&gt;1235365454&lt;/folder_id&gt;
                              &lt;/folder_ids&gt;
                          &lt;/image&gt;
                          &lt;image&gt;
                              &lt;value&gt;VALUE3&lt;/value&gt;
                              &lt;folder_ids&gt;
                                  &lt;folder_id&gt;3562377456&lt;/folder_id&gt;
                                  &lt;folder_id&gt;3566743626&lt;/folder_id&gt;
                                  &lt;folder_id&gt;012345678&lt;/folder_id&gt;
                              &lt;/folder_ids&gt;
                          &lt;/image&gt;
                          &lt;image&gt;
                              &lt;value&gt;VALUE4&lt;/value&gt;
                              &lt;folder_ids&gt;
                                  &lt;folder_id&gt;34627876&lt;/folder_id&gt;
                              &lt;/folder_ids&gt;
                          &lt;/image&gt;
                          &lt;image&gt;
  .
  .
  .
  </code></pre>
  <p>So for example if I need to find all values that contain 012345678 folder_id.
  I tried to use lxml library.
  Simple code:</p>
  <pre><code>from lxml import etree
  
  tree = etree.parse('D:\\test_nested_xml.xml')
  #root = etree.Element(&quot;root&quot;)
  for element in tree.iter(tag=&quot;folder_id&quot;):
      if element.text == '012345678':
          print(&quot;%s - %s&quot; % (element.text, element.getparent))
  </code></pre>
  <p>But in output I get following entries:</p>
  <pre><code>012345678 - &lt;bound method _Element.getparent of &lt;Element folder_id at 0x2cf2648&gt;&gt;
  012345678 - &lt;bound method _Element.getparent of &lt;Element folder_id at 0x2cf2620&gt;&gt;
  </code></pre>
  <p>And it is not what I need.</p>
  <p>Expected result for me is something like:</p>
  <pre><code>012345678 - VALUE1
  012345678 - VALUE3
  </code></pre>
  <p>Could someone help me how to correctly parse xml file and get what I need?</p>