Brace Expansion II

Given an expression that contains lowercase English letters, commas, and braces, expand it into every distinct string it can produce. A comma inside braces separates two or more alternatives, and adjacent pieces are concatenated. Braces may be nested. Return the expanded strings in lexicographic order.

Examples
Input: "{a,b}{c,{d,e}}"
Output: ["ac","ad","ae","bc","bd","be"]
Hints

Brace Expansion II

Given an expression that contains lowercase English letters, commas, and braces, expand it into every distinct string it can produce. A comma inside braces separates two or more alternatives, and adjacent pieces are concatenated. Braces may be nested. Return the expanded strings in lexicographic order.