def search_potential_deriv(expr, n, c=0):
    '\n    Retrieve the expressions at depth `n` that potentially stem from FD derivatives.\n    '
    assert (n >= c >= 0)
    if (q_leaf(expr) or expr.is_Pow):
        return []
    elif expr.is_Mul:
        if (c == n):
            return [expr]
        else:
            return flatten([search_potential_deriv(a, n, (c + 1)) for a in expr.args])
    else:
        return flatten([search_potential_deriv(a, n, c) for a in expr.args])
Retrieve the expressions at depth `n` that potentially stem from FD derivatives.
def search_potential_deriv(expr, n, c=0):
    '\n    \n    '
    assert (n >= c >= 0)
    if (q_leaf(expr) or expr.is_Pow):
        return []
    elif expr.is_Mul:
        if (c == n):
            return [expr]
        else:
            return flatten([search_potential_deriv(a, n, (c + 1)) for a in expr.args])
    else:
        return flatten([search_potential_deriv(a, n, c) for a in expr.args])