Fix bug where parent tag might have more than one child

e.g. cases like will cause the wrong node to be wrapped.