def _formula_str(formula, sep='&'):
    """Returns a representation of 'formula' for prettyprinting"""
    next_sep = '|' if sep == '&' else '&'
    items = [item if (type(item) == str) else _formula_str(item, next_sep)
             for item in formula]
    return '({0})'.format(' {0} '.format(sep).join(items))