def run_single_visitor(engine, visitorcallable, element, connection=None,
    **kwargs):
    """Taken from :meth:`sqlalchemy.engine.base.Engine._run_single_visitor`
    with support for migrate visitors.
    """
    if connection is None:
        conn = engine.connect()
    else:
        conn = connection
    visitor = visitorcallable(engine.dialect, conn)
    try:
        if hasattr(element, '__migrate_visit_name__'):
            fn = getattr(visitor, 'visit_' + element.__migrate_visit_name__)
        else:
            fn = getattr(visitor, 'visit_' + element.__visit_name__)
        fn(element, **kwargs)
    finally:
        if connection is None:
            conn.close()
