implements delete-duplicates(!) tail-recursively