The shadow of Chesterton's Fence is relevant. The LLM doesn't know why code exists, if it doesnt start traversing up the scope of a project. Even then, it can't be sure that the code isn't a dependency of something else outside the project (especially if there's a side effect). I'm not sure it's ever going to be easy to address this concern in a straightforward and portable way.
I do sometimes see duplicate functions, which is troubling.