After effects is in DIRE need of an edge extend tool. When dealing with keys or roto that has haloing and edge contamination issues and/or transparency from motion blur. To the best of my knoledge, there is no way in AE to extend the color and luminance values from the core of the key and extend them outward. This is a vital tool for correcting edges. I have been looking for over a decade for a tool or technique that can reliably to this in AE, and there isn't one. I literally have to have a Nuke artist do this for me.
Nuke has a myriad of tools for the the clean up of contaminated edges on roto or keys.
This is an example of what edge extend does in Nuke. this isn't an averaging of the overall pixels, it just extends the values outward so things like motion blur can be rebuilt.
Here's a video describing the process of using Color Smear with an actor very quickly crossing a bright monitor that needs screen replacement. this is something I do regularly, and it's a total pain in AE.
https://youtu.be/HUOzaV9gP5E?t=38