[Bug]: Naming of `@step`s in a `Workflow` affect whether the execution will halt

### Bug Description

Title says everything.

In section *Steps to Reproduce* I will give 2 code snippets with the same workflow, but steps are renamed. In the first case, everything works fine, but second case doesn't halt.

### Version

0.12.25

### Steps to Reproduce

I'm sorry, but I spent a lot of time finding this bug in my own `Workflow`. I then extracted it to a "sandbox" file and tried to make it as minimal as possible.

1) First case of naming - works:

Diagram:

![Image](https://github.com/user-attachments/assets/1c753800-0791-4095-ab03-f0c6086fe8af)

Yes, I really tried hard to minimize it.

```python
import asyncio
from typing import Optional
from llama_index.core.workflow import Context, Event, StartEvent, StopEvent, Workflow, draw_all_possible_flows, step


class Initial1(Event): ...
class Initial2(Event): ...

class Intermediate3(Event): ...
class Intermediate1(Event): ...
class Intermediate2(Event): ...
class Intermediate4(Event): ...


class TestWorkflow(Workflow):
    @step
    async def start(self, ctx: Context, ev: StartEvent) -> Initial1 | Initial2 | None:
        ctx.send_event(Initial1())
        ctx.send_event(Initial2())

    @step
    async def make_intermediate_1(self, ctx: Context, evs: Initial1) -> Optional[Intermediate1]:
        return Intermediate1()

    @step
    async def make_intermediate_2(self, ctx: Context, evs: Initial1 | Intermediate1) -> Optional[Intermediate2]:
        got = ctx.collect_events(evs, [Initial1, Intermediate1])
       
        if not got:
            return None

        return Intermediate2()

    @step
    async def make_intermediate_3(self, ctx: Context, evs: Initial2) -> Optional[Intermediate3]:
        return Intermediate3()

    @step
    async def make_intermediate_4(self, ctx: Context, evs: Initial1 | Intermediate1 | Intermediate3) -> Optional[Intermediate4]:
        got = ctx.collect_events(evs, [Initial1, Intermediate1, Intermediate3])
        
        if not got:
            return None
        
        return Intermediate4()

    @step
    async def finish(self, ctx: Context, evs: Intermediate1 | Intermediate2 | Intermediate3 | Intermediate4) -> Optional[StopEvent]:
        got = ctx.collect_events(evs, [Intermediate1, Intermediate2, Intermediate3, Intermediate4])

        if not got:
            return None

        return StopEvent()


async def main():
    w = TestWorkflow(verbose=True)
    draw_all_possible_flows(w, filename="test.html")
    await w.run()
    
    
asyncio.run(main())
```

Logs:

```plain
Running step start
Step start produced no event
Running step make_intermediate_1
Step make_intermediate_1 produced event Intermediate1
Running step make_intermediate_2
Step make_intermediate_2 produced no event
Running step make_intermediate_2
Step make_intermediate_2 produced event Intermediate2
Running step make_intermediate_3
Step make_intermediate_3 produced event Intermediate3
Running step make_intermediate_4
Step make_intermediate_4 produced no event
Running step make_intermediate_4
Step make_intermediate_4 produced no event
Running step make_intermediate_4
Step make_intermediate_4 produced event Intermediate4
Running step finish
Step finish produced no event
Running step finish
Step finish produced no event
Running step finish
Step finish produced no event
Running step finish
Step finish produced event StopEvent
```

2) Second case - different nameing - doesn't work:

Diagram:

![Image](https://github.com/user-attachments/assets/f6c0dd10-cddb-4298-9a11-e58c64a36885)

Code:

```python
import asyncio
from typing import Optional
from llama_index.core.workflow import Context, Event, StartEvent, StopEvent, Workflow, draw_all_possible_flows, step


class Initial1(Event): ...
class Initial2(Event): ...

class Intermediate3(Event): ...
class Intermediate1(Event): ...
class Intermediate2(Event): ...
class Intermediate4(Event): ...


class TestWorkflow(Workflow):
    @step
    async def start(self, ctx: Context, ev: StartEvent) -> Initial1 | Initial2 | None:
        ctx.send_event(Initial1())
        ctx.send_event(Initial2())

    @step
    async def make_intermediate_4(self, ctx: Context, evs: Initial1) -> Optional[Intermediate1]:
        return Intermediate1()

    @step
    async def make_intermediate_3(self, ctx: Context, evs: Initial1 | Intermediate1) -> Optional[Intermediate2]:
        got = ctx.collect_events(evs, [Initial1, Intermediate1])
       
        if not got:
            return None

        return Intermediate2()

    @step
    async def make_intermediate_2(self, ctx: Context, evs: Initial2) -> Optional[Intermediate3]:
        return Intermediate3()

    @step
    async def make_intermediate_1(self, ctx: Context, evs: Initial1 | Intermediate1 | Intermediate3) -> Optional[Intermediate4]:
        got = ctx.collect_events(evs, [Initial1, Intermediate1, Intermediate3])
        
        if not got:
            return None
        
        return Intermediate4()

    @step
    async def finish(self, ctx: Context, evs: Intermediate1 | Intermediate2 | Intermediate3 | Intermediate4) -> Optional[StopEvent]:
        got = ctx.collect_events(evs, [Intermediate1, Intermediate2, Intermediate3, Intermediate4])

        if not got:
            return None

        return StopEvent()


async def main():
    w = TestWorkflow(verbose=True)
    draw_all_possible_flows(w, filename="test.html")
    await w.run()
    
    
asyncio.run(main())
```

This fails:

```plain
Running step start
Step start produced no event
Running step make_intermediate_1
Step make_intermediate_1 produced no event
Running step make_intermediate_2
Step make_intermediate_2 produced event Intermediate3
Running step make_intermediate_3
Step make_intermediate_3 produced no event
Running step make_intermediate_4
Step make_intermediate_4 produced event Intermediate1
Running step finish
Step finish produced no event
Running step finish
Step finish produced no event
Running step make_intermediate_1
Step make_intermediate_1 produced event Intermediate4
Running step make_intermediate_1
Step make_intermediate_1 produced event Intermediate4
Running step make_intermediate_3
Step make_intermediate_3 produced no event
Running step finish
Step finish produced no event
Running step finish
Step finish produced no event
```

And then timeout error.

The only thing I changed is changed numerations of `make`s from 1 to 4, and in second case from 4 to 1

### Relevant Logs/Tracbacks

```shell

```

Labels: bug, triage
State: closed