title: Is it possible to iterator a ListNode with map() or reduce() function?
body: <p>I have a data structure like :</p>
  
  <pre><code>class ListNode:
      def __init__(self, x):
          self.val = x
          self.next = None
  </code></pre>
  
  <p>I want to iterator the ListNode one by one until the next is None</p>
  
  <p>I can use <code>while</code>, but is it possible to use map() or reduce() or something else to make the code more beautiful ?</p>