Quasi pseudo code food for thought ...
([color=blue]defun [/color][color=red]_PurgeAxdbDocument[/color] ( axdbDocument / purgeableCollections initialCount thisCount lastCount flag )
([color=blue]setq [/color]
purgeableCollections (_[color=red]GetPurgeAbleCollections [/color]axdbDocument)
initialCount ([color=blue]apply '+[/color] ([color=blue]mapcar [/color]'[color=red]_GetDeepCount [/color]purgeableCollections))
thisCount initialCount
flag T
)
([color=blue]while [/color]flag [color=green];; do at least once[/color]
([color=blue]foreach [/color]collection purgeableCollections
([color=red]_RecursivelyKillItWithFire[/color] collection)
)
([color=blue]setq [/color]
lastCount thisCount
thisCount ([color=blue]apply '+[/color] (mapcar '[color=red]_GetDeepCount[/color] purgeableCollections))
flag ([color=blue]/=[/color] lastCount thisCount)
)
)
([color=blue]princ [/color]([color=blue]strcat [/color][color=purple]"Purged "[/color] ([color=blue]itoa [/color]([color=blue]-[/color] initialCount thisCount)) [color=purple]" object(s).\n"[/color]))
([color=blue]princ[/color])
)