title: Finding the maximum depth of a binary tree
body: <pre><code>public class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode(int x) { val = x; }
  }
  
  public class Solution {
      public int maxDepth(TreeNode root) {
          TreeNode focusNode = root;
          TreeNode focusNode2 = root;
          int count = 0;
          int count1 = 0;
          boolean a = true;
          while (a) {
             if (focusNode != null) {
                 count++;
                 focusNode = focusNode.left;
             }
             if (focusNode2 != null) {
                 count++;
                 focusNode2 = focusNode2.right;
             } else {
                 a = false;
             }
          }
          return Math.max(count,count1);
      }
  }
  </code></pre>
  
  <p>I am confused why this code I wrote cannot give expected output. And I am also confused with the definition of maximum depth. Is finding maximum depth just considering all the nodes that line up on the left or line up on the right? </p>