fix checking parenthood in Container::remove()