title: how to check if list contains lists recursively
body: <p>I have a function in R that recursively builds a list of lists of varying depth. The output <code>node</code> may be be</p>
  
  <pre><code>node&lt;-list(right=(0))
  </code></pre>
  
  <p>or</p>
  
  <pre><code>node&lt;-list(right=list(right=0))
  </code></pre>
  
  <p>In Rcpp I would like to build a recursively deconstruct the list and return the integer member, 0 in this case. </p>
  
  <p>My problem is checking if <code>node</code> has a named member <code>right</code></p>
  
  <pre><code>library(Rcpp)
  
  cppFunction(
  '
  int predict(List node){
     if(node["right"]){
       return predict(node["right"]);
     }
     else{
       return node;
     }
   }
  }
  '
  )
  </code></pre>
  
  <p>I've looked at <a href="http://gallery.rcpp.org/articles/rcpp-wrap-and-recurse/" rel="nofollow noreferrer">Dynamic Wrapping</a> to check type and use switch/case, but it doesn't seem to like named lists.</p>