'Helper method to URL-serialize an OR-subtree in a query in
alternative field selector syntax if they all use the same
operator and value (this is needed to URL-serialize an
S3SearchSimpleWidget query).'

def _or(self):

    op = self.op
    l = self.left
    r = self.right
    if (op == self.AND):
        return None
    elif (op == self.NOT):
        (lname, lop, lval, linv) = l._or()
        return (lname, lop, lval, (not linv))
    elif (op == self.OR):
        lvars = l._or()
        rvars = r._or()
        if ((lvars is None) or (rvars is None)):
            return None
        (lname, lop, lval, linv) = lvars
        (rname, rop, rval, rinv) = rvars
        if ((lop != rop) or (linv != rinv)):
            return None
        if (lname == rname):
            return (lname, lop, [lval, rval], linv)
        elif (lval == rval):
            return (('%s|%s' % (lname, rname)), lop, lval, linv)
        else:
            return None
    else:
        return (l.name, op, r, False)
