networkx.algorithms.dag.
ancestors
Return all nodes having a path to source in G.
ancestors – The ancestors of source in G
set()