The unique operator computed the dedup key for non-scalar elements by
encoding them to YAML, which includes their head/line/foot comments. A
comment sitting between two otherwise equal objects attaches to one of
them, changing its encoding, so the duplicates were wrongly kept. Encode
a comment-free copy of the node for the key so uniqueness depends on the
data only.
Fixes#2491