def _iter_backtrack(ex, rand=False):
    """Iterate through all satisfying points using backtrack algorithm."""
    if ex is One:
        yield dict()
    elif ex is not Zero:
        if rand:
            v = random.choice(ex.inputs) if rand else ex.top
        else:
            v = ex.top
        points = [{v: 0}, {v: 1}]
        if rand:
            random.shuffle(points)
        for point in points:
            for soln in _iter_backtrack(ex.restrict(point), rand):
                soln.update(point)
                yield soln
def _iter_backtrack ( ex , rand = False ) : if ex is One : yield dict ( ) elif ex is not Zero : if rand : v = random . choice ( ex . inputs ) if rand else ex . top else : v = ex . top points = [ { v : 0 } , { v : 1 } ] if rand : random . shuffle ( points ) for point in points : for soln in _iter_backtrack ( ex . restrict ( point ) , rand ) : soln . update ( point ) yield soln
Iterate through all satisfying points using backtrack algorithm.