import copy


def copy_table(document, table, cut=False):
    """
    Copy a table and append it to the end of the document.
    :param document: A python-docx document object
    :param table: A python-docx table object
    :param cut: Instead of duplicating a the table, move it to the end
                of the document
    :return: The newly created table instance
    """
    if cut:
        document._body._element._insert_tbl(table._tbl)
    else:
        document._body._element._insert_tbl(copy.deepcopy(table)._tbl)
    return document.tables[-1]