title: Python minidom hangs PySide application
body: <p>I'm making an application using PySide. I have a directory tree widget which should list the directory view with certain predefined depth. Mostly these folders will be from a server location. I'm using glob module to list folders with predefined depth. And I build an xml document with this directory list using minidom module which will be later used to build items in tree widget.
  But at some point my app freezes and turns out to be non responsive. Here is my code.</p>
  
  <pre><code>import glob, os
  from xml.dom import minidom
  dirs = []
  limit = 3
  root = "S:/assets"
  for i in range(1, limit + 1):
      depth = []
      [depth.append(
          os.path.abspath(x)) for x in glob.glob(
          root + "/*" * i)]
      for each in depth:
          if "." not in os.path.split(each)[-1]:
              dirs.append(each)
  dirs.sort()
  
  def showDirectory(base, dirs):
      dirDict = {}
      doc = minidom.Document()
      root = doc.createElement("root")
      for each in dirs:
          items = os.path.split(each)
          if items[-1] == "":
              continue
          elm = doc.createElement("dir")
          elm.appendChild(doc.createTextNode(items[-1]))
          par = os.path.split(items[0])[-1]
          dirDict[items[-1]] = elm
          if os.path.abspath(items[0]) == os.path.abspath(base):
              dirDict[items[-1]] = root.appendChild(elm)
          else:
              dirDict[par].appendChild(elm) # this line is the problem
      doc.appendChild(root)
      return doc
  
  # test
  with open("D:/test.xml", "w") as f:
      showDirectory(root, dirs).writexml(f)
  </code></pre>
  
  <p>Problem is not with my app as the same tree widget is being used in many other scenario. If I comment the line I marked as problematic, everything works just fine.</p>
  
  <p>Am I doing something wrong? Any help is really appreciated.
  Thanks</p>