If you're going to leave it like this, you'll need to at least check that items.Size() > 0 and that items[1]->IsParentFolder() prior to removing the item.