I  remember there was an incantation to work with expanded doif's etc. 
In this case I need \doifelsedefined{ARG} with ARG expanded.
I lost the exact spelling of the command and dldn't find it in the garden. 
What was it?

yours sincerely
dr. Hans van der Meer