Refactor block matching logic in compound matchers.