def METHOD_NAME(id, session=None, sim=None):
    if session is None:
        session = get_default_session()
    if isinstance(id, str) or isinstance(id, str):
        if sim is None:
            sim, ts = id.split("/")
            sim = get_simulation(sim, session)
        else:
            ts = id
        res = session.query(TimeStep).filter(
            and_(TimeStep.extension.like(ts), TimeStep.simulation_id == sim.id))
        num = res.count()
        if num == 0:
            raise RuntimeError("No timestep matches for %r" % id)
        elif num > 1:
            raise RuntimeError("Multiple (%d) matches for timestep %r of simulation %r" % (
                num, ts, sim))
        else:
            return res.first()
    else:
        return session.query(TimeStep).filter_by(id=int(id)).first()