Many thanks for the reply. I'm glad to see you've looked beyond the specific implementation. Your ideas are certainly worth thought.
I will almost certainly play with the idea in your 2nd point. I may be painting myself into a corner with my current recursive implementation. Your idea seems a lot more flexible, and will probably lead to definitions that are simpler to understand (at least for some definition of "understand").
I must admit the Prolog-esque solution sounds like a lot of fun. I'm not sure it would be worth the conceptual hurdle, but then again, maybe it would! Hmm.