code: def getTableMisnestedNodePosition(self):
          
          # The foster parent element is the one which comes before the most
          # recently opened table element
          # XXX - this is really inelegant
          lastTable = None
          fosterParent = None
          insertBefore = None
          for elm in self.openElements[::-1]:
              if elm.name == "table":
                  lastTable = elm
                  break
          if lastTable:
              # XXX - we should really check that this parent is actually a
              # node here
              if lastTable.parent:
                  fosterParent = lastTable.parent
                  insertBefore = lastTable
              else:
                  fosterParent = self.openElements[
                      self.openElements.index(lastTable) - 1]
          else:
              fosterParent = self.openElements[0]
          return fosterParent, insertBefore
docs: Get the foster parent element, and sibling to insert before
          (or None) when inserting a misnested table node