private void OnGameObjectRemoved(GameObjectRemovedMessage msg) { if (_gameObjectLookup.ContainsKey(msg.GameObjectId)) { // .ToList() to bring in local copy as we will be removing from the list we are iterating over foreach (var node in _gameObjectLookup[msg.GameObjectId].ToList()) { RemoveComponent(node); } } }