def get_graphlist(gg, l=None):
    """Traverse a graph with subgraphs and return them as a list"""
    if not l:
        l = []
        outer = True
    else:
        outer = False
    l.append(gg)
    if gg.get_subgraphs():
        for g in gg.get_subgraphs():
            get_graphlist(g, l)
    if outer:
        return l