Making progress with a Subexpression-based approach, but not quite working yet (Python-only currently)