title: Use promises with recursive function
body: <p>I am trying to figure out if it's possible to use promises instead of a standard callback in a recursive function.</p>
  
  <p>The way I have it now:</p>
  
  <pre><code>function recursive(data, cb){
  
       (function promiseProvider(data){
  
            return newThenable(data).then(function(val){
                   if(val.a){
                      cb(null, val);
                   }
                   else {
                      return promiseProvider(val);
                   }
  
            });
  
       })(data);
  
  }
  </code></pre>
  
  <p>This works, but I can't figure out how I could make a pure promise implementation.</p>
  
  <p>Perhaps this would work?</p>
  
  <pre><code>  function recursive(data){
  
        return newThenable(data).then(function(val){
                 if(val.a){
                    return // &lt;&lt;&lt; ???
                   }
                   else {
                     return recursive(val);
                   }
  
          });
  
       }
  </code></pre>
  
  <p>However, that doesn't work.</p>