Fix orphan node bug

Checkout whether the parent of node is DOCUMENT type.
If not, node is orphan.
Remove relationship