title: How to get all child nodes with name in Swift with Scene Kit
body: <p>I am trying to develop a basic game and I have a scene with several child nodes added to the root node. Each node has one of two names, either <code>friend</code> or <code>enemy</code>. </p>
  
  <p>If a user touches one of the <code>enemy</code> nodes I want to remove <em>all</em> child nodes that are named <code>enemy</code>.</p>
  
  <p>I have tried several things, but can't seem to get anything working.</p>
  
  <p>In my <code>touchesBegan</code> function:</p>
  
  <pre><code>override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
     let touch = touches.first!
     let location = touch.location(in: gameView)
     let hitList = gameView.hitTest(location, options: nil)
  
     if let hitObject = hitList.first {
        let node = hitObject.node
  
        //This doesn't work
        gameScene.rootNode.childNodes(passingTest: { (node, UnsafeMutablePointer&lt;ObjCBool&gt;) -&gt; Bool in 
        node.removeFromParentNode()
     } 
  }
  </code></pre>
  
  <p>I have also tried to use <code>gameScene.rootNode.enumerateChildNodes(withName:)</code> but I can't get that working either.</p>
  
  <p>What I <em>can</em> get working is if I do something like this in there instead:</p>
  
  <pre><code>if node.name == "enemy" {
      node.removeFromParentNode()
  }
  </code></pre>
  
  <p>However this will only remove the single node that was hit, not all of them. How can I get all of the child nodes with a certain name in Swift with Scene Kit?</p>