Speaking as someone who maintains a fair bit of legacy infrastructure for a living, the hard part is knowing what is unused and what isn't. That's the whole rationale behind Linus' "don't break user space" policy.
[1] https://en.wikipedia.org/wiki/Wikipedia:Chesterton's_fence
“Beware of the bull”
"Chesterton's Permalinked Fence" is generally straightforward to reason about.
Or what I run into “Is this used …. and does it even ‘work’?!?!”
Another system watched the version control system for who added that line of logging, and sent them status emails. After the moribund logging had been in production for two weeks, the emails turned into nag emails to either remove the code, or at least remove the moribund logging if you decided against removing the code.