def wait_for_dependencies(world, sim):
    """
    Return an event (:class:`simpy.events.AllOf`) that is triggered when
    all dependencies can provide input data for *sim*.

    Also notify any simulator that is already waiting to perform its next step.

    *world* is a mosaik :class:`~mosaik.scenario.World`.
    """
    events = []
    t = sim.next_step
    dfg = world.df_graph
    for dep_sid in dfg.predecessors(sim.sid):
        dep = world.sims[dep_sid]
        if t in world._df_cache and dep_sid in world._df_cache[t]:
            continue
        evt = world.env.event()
        events.append(evt)
        world.df_graph[dep_sid][sim.sid]['wait_event'] = evt
        if not dep.step_required.triggered:
            dep.step_required.succeed()
    for suc_sid in dfg.successors(sim.sid):
        suc = world.sims[suc_sid]
        if dfg[sim.sid][suc_sid]['async_requests'] and suc.next_step < t:
            evt = world.env.event()
            events.append(evt)
            world.df_graph[sim.sid][suc_sid]['wait_async'] = evt
    clg = world.shifted_graph
    for dep_sid in clg.predecessors(sim.sid):
        dep = world.sims[dep_sid]
        if dep.next_step < t:
            evt = world.env.event()
            events.append(evt)
            clg[dep_sid][sim.sid]['wait_shifted'] = evt
    return world.env.all_of(events)
