'Generate exactly one reference to each of the parts in the package by
performing a depth-first traversal of the rels graph.'

def iter_parts(self):

    def walk_parts(source, visited=list()):
        for rel in source.rels.values():
            if rel.is_external:
                continue
            part = rel.target_part
            if (part in visited):
                continue
            visited.append(part)
            (yield part)
            new_source = part
            for part in walk_parts(new_source, visited):
                (yield part)
    for part in walk_parts(self):
        (yield part)
