Merge Composites

Hey, I’m trying to write a pattern for merge_composites such that I want to match an entire if block when a particular condition is met (lets call it X).

I tried is_if(X, wildcard(), wildcard()) but it only takes the condition X and the if statement inside the composite function - the actual “true branch” body and “false branch” body are taken as inputs to the composite function. How can I make it such that the entire body of the true and false branches (whatever they might be) are also fully inside my composite function if the condition X is being met?

Thanks!