[PATCH] Test parent tag existence before query for its id