def __solve_and_destructure_repeated(expr, vars):
iterable, isrepeating = __solve_for_repeated(expr, vars)<EOL>if iterable is None:<EOL><INDENT>return (), isrepeating<EOL><DEDENT>if not isrepeating:<EOL><INDENT>return [iterable], False<EOL><DEDENT>values = iter(iterable)<EOL>try:<EOL><INDENT>value = next(values)<EOL><DEDENT>except StopIteration:<EOL><INDENT>return (), True<EOL><DEDENT>if not isinstance(value, row_tuple.RowTuple):<EOL><INDENT>result = [value]<EOL>result.extend(values)<EOL>return result, True<EOL><DEDENT>try:<EOL><INDENT>result = [value.get_singleton()]<EOL>for value in values:<EOL><INDENT>result.append(value.get_singleton())<EOL><DEDENT>return result, True<EOL><DEDENT>except ValueError:<EOL><INDENT>raise errors.EfilterTypeError(<EOL>root=expr, query=expr.source,<EOL>message="<STR_LIT>" % (value,))<EOL><DEDENT>
Helper: solve 'expr' always returning a list of scalars.

    If the output of 'expr' is one or more row tuples with only a single column
    then return a repeated value of values in that column. If there are more
    than one column per row then raise.

    This returns a list because there's no point in wrapping the scalars in
    a repeated value for use internal to the implementing solver.

    Returns:
        Two values:
         - An iterator (not an IRepeated!) of scalars.
         - A boolean to indicate whether the original value was repeating.

    Raises:
        EfilterTypeError if the values don't conform.