def METHOD_NAME(
    self,
    input_names: List[str],
    output_names: List[str],
) -> List[NodeProto]:
    reachable_nodes = list()  # type: ignore
    for name in output_names:
        self._dfs_search_reachable_nodes(name, input_names, reachable_nodes)
    # needs to be topology sorted.
    nodes = [n for n in self.graph.node if n in reachable_nodes]
    return nodes