recursive_simple_cycles from NetworkX can be used:
recursive_simple_cycles
import networkx as nx list(nx.recursive_simple_cycles(nx.DiGraph(a)))