Added check in cosmos for non-existant parent_id

First ever commit with test. See how it works. Also, I had it ready like 5 days ago but completely forgot to make the pull request.