I suspect my initial post was far too ugly for anyone to make sense of. And in fact the expression I was looking at was correctly labeled as type Add.
But I'm still not getting what I want. A much simpler example is:
x,y,z,n,p = symbols('x y z n p')
expr1 = z * (y * x + y * p) + n
expr2 = collect(expr1,y)
Both expr1 and expr2 yield:
n + z*(p*y + x*y)
However, I was hoping that expr2 would yield:
n + z * (y * (p + x))
If I subtract n from either expr1 or expr2, yielding:
expr3 = z*(p*y + x*y)
and then run collect(expr3, y), then I get what I'm looking for:
z * y * (p + x)
Finally:
collect(n + p*y + x*y, y) yields n + y * (p +x) as I would hope.
So it appears that collect doesn't give me the result in the special case where I have addition as well as undistributed multiplication. Sorry for what probably seems like a menial question. However, it's important for me to understand what's going on here as I try to simplify some very complicated expressions to input into a finite element code. Is there a better function for achieving what I want to achieve here?