prevent duplicates in n-ary order