'Create an element and insert it into the tree'

def insertElementTable(self, token):

    element = self.createElement(token)
    if (self.openElements[(-1)].name not in tableInsertModeElements):
        return self.insertElementNormal(token)
    else:
        (parent, insertBefore) = self.getTableMisnestedNodePosition()
        if (insertBefore is None):
            parent.appendChild(element)
        else:
            parent.insertBefore(element, insertBefore)
        self.openElements.append(element)
    return element
