def convert_exp(exp):
    if hasattr(exp, 'exp'):
        exp_nested = exp.exp()
    else:
        exp_nested = exp.exp_nofunc()
    if exp_nested:
        base = convert_exp(exp_nested)
        if isinstance(base, list):
            raise Exception('Cannot raise derivative to power')
        if exp.atom():
            exponent = convert_atom(exp.atom())
        elif exp.expr():
            exponent = convert_expr(exp.expr())
        return sympy.Pow(base, exponent, evaluate=False)
    elif hasattr(exp, 'comp'):
        return convert_comp(exp.comp())
    else:
        return convert_comp(exp.comp_nofunc())
def convert_exp(exp):
    if hasattr(exp, 'exp'):
        exp_nested = exp.exp()
    else:
        exp_nested = exp.exp_nofunc()
    if exp_nested:
        base = convert_exp(exp_nested)
        if isinstance(base, list):
            raise Exception('Cannot raise derivative to power')
        if exp.atom():
            exponent = convert_atom(exp.atom())
        elif exp.expr():
            exponent = convert_expr(exp.expr())
        return sympy.Pow(base, exponent, evaluate=False)
    elif hasattr(exp, 'comp'):
        return convert_comp(exp.comp())
    else:
        return convert_comp(exp.comp_nofunc())