Your losing me here. I have explained the default working of the code. If you use the categall template the thumbnail shown is either the category avatar or the last photo uploaded to that cat or its children. There is no way around that. That is just how the product works.