dom/node: check if a parent exist before wrapping it