title: How to find all possible subtrees of a binary tree in Haskell?
body: <p>I need to find all possible subtrees in a binary tree:</p>
  
  <pre><code>allSubtrees :: BinaryT a -&gt; [BinaryT a]
  allSubtrees = undefined
  </code></pre>
  
  <p>and the tree is:</p>
  
  <pre><code>data BinaryT a =
      Empty
    | Node (BinaryT a) a (BinaryT a)
    deriving (Eq, Show)
  </code></pre>
  
  <p>I'm new to Haskell and I know there's no <code>while</code> &frasl; <code>for</code> loop in Haskell. Haskell is all about recursion. My question is, how to get all the possible subtrees of a tree without infinite recursion?</p>