[YAML] fix merge node (<<)

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | yes but according to spec
| Deprecations? | no
| Tests pass?   | yes
| Needs merge to | 2.5
| Fixed tickets | #11142 and #11154
| License       | MIT
| Doc PR        | —

First commit small refactoring.
Second fixes #11154 (causing a BC break for a less common feature)
Third fixes #11142