replacement – Making a rule that only applies when the expression is NOT an argument?

I know we can make rules of the kind:

magic/:f_[x___,magic[a_],y___]:=f[x,arg[a],y]

This will replace magic[a] by arg[a] whenever magic[a] is the argument of a function.

Suppose I want arg[a] to be replaced by a, but only when arg[a] is NOT the argument of a function. Ie. I want a rule that applies only on top-level, only in those situations where the first pattern would not apply. Making arg[a_] := a is inadequate. In pseudocode it would be arg[a_] := a /; Not[FunctionArgument[arg[a]]].
Is this possible to achieve in Mathematica?