'Convert an array expression tree into a set of operators.'

def _array_expr_to_set(self, expr, out=None):

    if (out is None):
        out = set()
    if (not isinstance(expr, tuple)):
        raise ValueError('{0}    not    a    tuple'.format(expr))
    (operation, operands) = expr
    processed_operands = []
    for operand in operands:
        if isinstance(operand, tuple):
            (operand, _) = self._array_expr_to_set(operand, out)
        processed_operands.append(operand)
    processed_expr = (operation, tuple(processed_operands))
    out.add(processed_expr)
    return (processed_expr, out)
