now with enhanced Metanome compatibility
recursive implementation - Metanome compatible but doesn't seem to catch all combinations