Mie Loop If Is First ๐
Do one thing on the first pass, another on the rest
- loop_ctx
- then_value
- else_value
- loop_ctx
- value
A branch node built for one very common loop pattern: on the first iteration, use one value; on every later iteration, use another. MieLoopIfIsFirst checks whether the loop is on its opening pass and passes through either then_value or else_value accordingly.
Part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, under the ๐ Loop submenu.
Why you'd reach for it
The killer use is a feedback loop, where each pass takes the previous pass's output as its input. The problem: on the very first iteration there is no previous output yet. So you branch - first pass grabs a seed image (or an empty latent, or a starting prompt), and every pass after that grabs the carried-forward result. That "seed once, then chain" shape is exactly what this node encodes, in one node instead of a tangle of comparisons.
It's the same idea as reading the index and testing == 0 yourself, but cleaner and self-documenting. If your condition is genuinely "is this pass number zero," this reads better than wiring up MieLoopGetIndex and a comparator.
The inputs and outputs that matter
loop_ctx(MIE_LOOP_CTX) - the loop context; this is how the node knows the current position.then_value(any type, optional) - what to output on the first iteration.else_value(any type, optional) - what to output on every other iteration.
Outputs:
loop_ctx- passed straight through, so you can keep the loop chain going.value(any type) -then_valueon the first pass,else_valueotherwise.
Both value inputs are the wildcard * type, so this works for images, latents, strings, numbers - whatever you're switching between. Just keep both branches the same type as what's downstream.
Installing it
ComfyUI Manager โ search ComfyUI-MieNodes โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
then restart. No model downloads or heavy dependencies. Under ๐ MieNodes โ ๐ Loop.
Common issues
Both branches evaluate anyway. ComfyUI generally computes upstream nodes regardless of which branch is selected - the node picks the output, it doesn't prune the graph. If the unused branch is expensive, that cost may still be paid. Structure heavy work so it isn't dangling off a branch you're not using.
Type mismatch downstream. then_value and else_value are wildcards, so nothing stops you from feeding an image into one and a string into the other. The node won't complain, but whatever consumes value will. Keep both branches the same type.
I want the last pass, or an arbitrary index. Use MieLoopIfIsLast for the final iteration, or MieLoopIfCurrentIdx for any comparison like >= 3.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ | |
| then_valueopt | * | โ | |
| else_valueopt | * | โ |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ |
| value | * | โ |