def allpredecessors(obsstore, nodes, ignoreflags=0):
    """Yield node for every precursors of <nodes>.

    Some precursors may be unknown locally.

    This is a linear yield unsuited to detecting folded changesets. It includes
    initial nodes too."""
    remaining = set(nodes)
    seen = set(remaining)
    prec = obsstore.predecessors.get
    while remaining:
        current = remaining.pop()
        yield current
        for mark in prec(current, ()):
            if mark[2] & ignoreflags:
                continue
            suc = mark[0]
            if suc not in seen:
                seen.add(suc)
                remaining.add(suc)
