code: def _parseDOM(istack):
      
      ostack = []
      end_tag_index = 0
  
      def neither_nonpair_or_end_or_comment(el):
          return not (el.isNonPairTag() or el.isEndTag() or el.isComment())
  
      index = 0
      while index < len(istack):
          el = istack[index]
  
          # check if this is pair tag
          end_tag_index = _indexOfEndTag(istack[index:])
  
          if end_tag_index == 0 and neither_nonpair_or_end_or_comment(el):
              el.isNonPairTag(True)
  
          if end_tag_index == 0:
              if not el.isEndTag():
                  ostack.append(el)
          else:
              el.childs = _parseDOM(istack[index + 1: end_tag_index + index])
              el.endtag = istack[end_tag_index + index]  # reference to endtag
              el.endtag.openertag = el
  
              ostack.append(el)
              ostack.append(el.endtag)
  
              index = end_tag_index + index
  
          index += 1
  
      return ostack
docs: Recursively go through element array and create DOM.
  
      Args:
          istack (list): List of :class:`.HTMLElement` objects.
  
      Returns:
          list: DOM tree as list.