Fix assert on Node::parentNode() for root
Before this commit, because of both parentNode() not checking
for parent() existing and createNode() not checking for the node
existing (which in this case was originalNode->parent()),
trying to access parentNode() of root node would result in an assert
or crash.
This commit fixes that behaviour in both places.
BUG:420317
(cherry picked from commit 2a391d814b0a46624bd8ddd6b29ae1498397187c)