4.41 On the order of terms when using indents

I was trying to match on anyfunction that has \(x\) inside its arguments. It turned out that matching \(f(a x)\) vs. \(f(a+x)\) needed to have the identical(x) being placed first when it is a sum and last when it is a product. Very strange. Just be aware of this

indets(f(a+x),function(`&+`(anything,identical(x)))); 
#failed 
    {}
 

But

indets(f(a+x),function(`&+`(identical(x),anything))); 
 
   {f(x + a)}
 

While with product, it is the other way around

indets(f(a*x),function(`&*`(anything,identical(x)))); 
 
    {f(a*x)}
 

But now this fail

indets(f(a*x),function(`&*`(identical(x),anything))); 
#fail 
    {}
 

I have not yet figure how to tell it that the order does not matter. Maple 2023.1

A better way than the above, if I want to find any function that takes in \(x\) or \(y\) as arguments is to use patfunc like this

indets(f(a*x+b+y),patfunc(anything,`Or`({identical(x),identical(y)}))); 
     {f(a*b + y)} 
 
indets(f(b+y),patfunc(anything,`Or`({identical(x),identical(y)}))); 
     {f(b + y)} 
 
indets(exp(a*x),patfunc(anything,`Or`({identical(x),identical(y)}))); 
      {exp(a*x)} 
 
indets(exp(a+x),patfunc(anything,`Or`({identical(x),identical(y)}))); 
{exp(x + a)}