Reduce duplication
Move some duplicated code blobs into a function. Share the code that iterates the declarations in a TopDUContext in DeclarationId.