The yamllint command line tool does what you want:
sudo pip install yamllint
In particular, it has a key-duplicates rule that detects key-duplicates and keys by rewriting each other:
$ yamllint test.yaml test.yaml 1:1 warning missing document start "---" (document-start) 10:5 error duplication of key "subkey5" in mapping (key-duplicates)
(It has many other rules that you can enable / disable or configure.)
source share