Added a check to make sure a parent node exists in call remove() to avoid errors as seen in bug #1742.