Traditionally (pre-ai) you would use another image of the same part of the sky and negate the items that you want to remove from the image
As an example terrestrial telescope mirrors get dusty. You're not going to break down the scope just to clean up the dust as this is a many days operation in most cases. So instead you would take "flats" that were of a pure white background and thus showed the dust in its full, dusty, glory. When you take your actual images, you negate (subtract from the original image) the flat and thus any noise generated by the dust. You can use this same method for removing brighter stars from an image that would otherwise saturate the ccd and wash out the background. Turns out it doesn't work for planes. Ask me how I know!
Why does the technique not work with aircraft? Because they generally fly on fixed routes?