title: How to recursively iterate over Swift Syntax with SwiftSyntax library?
body: <p>I would like to iterate in my code over the Swift AST like this, finding the struct keyword.</p>
  <pre><code>private func recursion(node: Syntax) -&gt; String {
      for child in node.children {
          if let tokenKind = (child as? TokenSyntax)?.tokenKind, tokenKind == .structKeyword {
         // if type(of: child) == StructDeclSyntax.self {
              print (&quot;yeah&quot;)
          }
  
          recursion(node: child)
      }
  }
  
  let input = &quot;&quot;&quot;
          public struct cmd_deleteEdge&lt;E: VEdge&gt; : EdgeCommand {
              public var keyEquivalent = KeyEquivalent.none
              public let title = &quot;Delete Edge&quot;
              public let id = &quot;deleteEdge&quot;
              public let toolTip = &quot;Delete selected Edge&quot;
              public let icon = Icon.delete
              
              //receivers
              public let edge: E
              
              public init(edge: E) {
                  self.edge = edge
              }
              
              public func execute() throws -&gt; ActionResult {
                  edge.deleteYourself()
                  return .success(&quot;deleted edge&quot;)
              }
          }
  &quot;&quot;&quot;
  
  public func convert(structText: String) throws -&gt; String  {
      let sourceFile = try SyntaxParser.parse(source: structText)
      let result = recursion(node: Syntax(sourceFile))
      return result
  }
  
  
  try convert(structText: input)
  </code></pre>
  <p>It just simply doesn't work, I never reach the &quot;Yeah&quot; (which means I cannot do anything useful during the recursion).</p>
  <p>I find this library very confusing. Would anyone have a good UML diagram explaining how it really works?</p>
  <p>Before you tell me, yes I know I could use a Visitor, but I want to understand how it works by myself.</p>