title: how does this python "for" compound statement work?
body: <p>I saw the following solution for <a href="https://leetcode.com/problems/n-ary-tree-level-order-traversal/" rel="nofollow noreferrer">a problem on leetcode</a>:</p>
  
  <pre><code>class Solution:
      def levelOrder(self, root):
          """
          :type root: Node
          :rtype: List[List[int]]
          """
  
          if root is None:
              return []
  
          q, res = [root], []
          q1 = []
          while q:
              res.append([node.val for node in q])
              q = [child for node in q for child in node.children]
  
          return res
  </code></pre>
  
  <p>How does <code>[child for node in q for child in node.children]</code> work? What does child mean when you place it before the for loop statement? </p>