def reachable(stepFunction, start, destinations, _alreadyseen=None):
    """ Determines the subset of destinations that can be reached from a set of starting positions,
    while using stepFunction (which produces a list of neighbor states) to navigate.
    Uses breadth-first search.
    Returns a dictionary with reachable destinations and their distances.
    """
    if len(start) == 0 or len(destinations) == 0:
        return {}
    if _alreadyseen is None:
        _alreadyseen = []
    _alreadyseen.extend(start)

    # dict with distances to destinations
    res = {}
    for s in start:
        if destinations in s:
            res[s] = 0
            start.remove(s)

    # do one step
    new = set()
    for s in start:
        new.update(stepFunction(s))
    new.difference_update(_alreadyseen)
    ndestinations = list(destinations)

    for s in list(new):
        if s in destinations:
            res[s] = 1
            new.remove(s)
            ndestinations.remove(s)
            _alreadyseen.append(s)

    # recursively do the rest
    deeper = reachable(stepFunction, new, ndestinations, _alreadyseen)

    # adjust distances
    for k, val in list(deeper.items()):
        res[k] = val + 1
    return res
dataset/ETHPy150Open pybrain/pybrain/pybrain/utilities.py/reachable/swapped operands of `in`