GE HealthCare Edison workflow rules may contain nested parenthesized groups. Given a list of valid expressions, group expressions that are structurally equivalent when the order of items at every nesting level is ignored.
An item is either a lowercase letter or a parenthesized expression. Letters at the same level may be rearranged, and parenthesized groups at the same level may also be reordered. Equivalence is recursive, so nested groups must satisfy the same rule. Parentheses themselves define structure and cannot be removed or added.
Return groups of equivalent expression indices in ascending first-occurrence order. Indices inside each group must also be ascending.
Implement group_expressions(expressions), where expressions is a list of strings containing lowercase English letters and parentheses. Return a list of lists of zero-based indices. Every input expression is guaranteed to have balanced parentheses.
def group_expressions(expressions):