OK, looking more carefully at this here (and especially after you "spelled out" the cases better) I can see that this should simply be 

```
if symbol not in substituted.free_symbols:
    return substituted.as_independent(u_var, as_Add=False)
return False
```

The reason is that if symbol is not in `substituted` it is impossible for it to be in `constant`.  That being said, it is not obvious that this is doing the same thing as the old code. For example, there is no replacement of `u_var` with `u` in your code. Can you comment on the rationale for this change?