def METHOD_NAME(
    graph: "DiGraph",
    nodes: Optional[List] = None,
    pipeline: bool = False,
    downstream: bool = False,
) -> "DiGraph":
    import networkx as nx
    from .graph import get_pipeline, get_pipelines, get_subgraph_of_nodes
    if not pipeline or not nodes:
        return get_subgraph_of_nodes(graph, nodes, downstream=downstream)
    pipelines = get_pipelines(graph)
    used_pipelines = [get_pipeline(pipelines, node) for node in nodes]
    return nx.compose_all(used_pipelines)