I think when you break it down into what is actually unique there's not that much to DRY up here and I think the code being here is more expressive than any function name I could introduce.

With that said I agree it still stands out as unclean but this file has a lot of accidental complexity already and I think it would all benefit from a rewrite based on a new pattern; visitor potentially.

As it stands I'm happy with this addition because it's makes the implementation behave in a more logical way, but I think any future improvements or extensions should prompt a cleanup beforehand.