chore: clean up some iteration logic in DumpAsDot (#5275)

2 files changed