def getbranches(tree):
    if isinstance(tree, tuple):
        name, subtree = tree
        a = [name]
        for st in subtree:
            a.extend(getbranches(st))
        return a
    return []
walk tree to get list of branches
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/sandbox/regression/treewalkerclass.py/getbranches