def METHOD_NAME(self, vertices: Iterable[N]) -> "DAG[N]":
    vertices = frozenset(vertices)
    subgraph = self.copy()
    to_remove = set(self.nodes) - vertices
    for v in vertices:
        node = v
        parent = None
        while True:
            parents = tuple(subgraph.predecessors(node))
            if not parents:
                if parent is not None:
                    subgraph.remove_edge(parent, v)
                    subgraph.add_edge(node, v)
                break
            assert len(parents) == 1
            ancestor = parents[0]
            if parent is None:
                parent = ancestor
            if ancestor in vertices:
                to_remove.add(v)
                break
            node = ancestor
    subgraph.remove_nodes_from(to_remove)
    return subgraph