title: Find maximum length of path with only 1
body: <p>I have a tree consisting of only binary numbers as node data. Now I must find the maximum length of the path which consist only of nodes that has its node value as 1 and path must be continuous i.e it should not contain any zero on its way.</p>
  
  <p>For example, let's consider this tree:</p>
  
  <pre><code>root-&gt;data = 0;
  root-&gt;left-&gt;data = 1;
  root-&gt;right-&gt;data = 0;
  root-&gt;left-&gt;left-&gt;data = 1;
  root-&gt;left-&gt;right-&gt;data = 1;
  root-&gt;left-&gt;left-&gt;left-&gt;data = 1;
  root-&gt;left-&gt;right-&gt;left-&gt;data = 1;
  root-&gt;left-&gt;right-&gt;right-&gt;data = 0;
  </code></pre>
  
  <p>The answer of above tree should be 5.
  Please refer  to figure in the link given below:</p>
  
  <p><a href="http://i.stack.imgur.com/KstEZ.png" rel="nofollow">Click this for more detail</a></p>
  
  <p>How can I do this?</p>