def METHOD_NAME(conn, no_recurse=False):
    # try to find the master
    q = sa.select([tbl.c.id],
                  whereclause=whereclause)
    r = conn.execute(q)
    row = r.fetchone()
    r.close()
    # found it!
    if row:
        return row.id, True
    if not autoCreate:
        return None, False
    if _race_hook is not None:
        _race_hook(conn)
    try:
        r = conn.execute(tbl.insert(), [insert_values])
        return r.inserted_primary_key[0], False
    except (sa.exc.IntegrityError, sa.exc.ProgrammingError):
        # try it all over again, in case there was an overlapping,
        # identical call, but only retry once.
        if no_recurse:
            raise
        return METHOD_NAME(conn, no_recurse=True)