Replace a big loop + dict lookup in Connection.execute() with a simple visitor pattern