A sequence containing a match followed by a leaf should just return the leaf.
Replace remainder string with struct which also includes the current index of the remainder into the initial input.
Tidy.
Properly record indices where matches are found in sequences.
Refactor.
Fix leaf equality test to include remainder comparison.
Extract refactor.
Extract refactor.
Extract refactor.
Improve test clarity.
Repeat minimum 1 without match fails.
Repeat minimum 1 with match matches.
Repeat minimum 2 without enough matches fails.
Repeat minimum 2 with 2 matches succeeds.
Amend test to cover more cases.
Permit 0 matches.
Repeat matches up to maximum times.
Successfully match number of repeated expressions between minimum and maximum.
Handle 0 or 1 repeats.
Simplify repeat logic.