title: Not getting correct path for some points from root node to the point in java
body: <p>I am trying to find out path from root node to a given point by using recursive algorithm. I am getting correct path for some of the points but for some points, I am getting the incorrect path. Please check below link for detailed description about the problem.</p>
  
  <p><a href="https://www.docdroid.net/X38NJJZ/problem-statement.docx" rel="nofollow noreferrer">Problem Statement</a></p>
  
  <p>I have tried below code for this <a href="https://www.docdroid.net/KNwEZun/input.txt" rel="nofollow noreferrer">input</a> and <a href="https://www.docdroid.net/GEvHkJR/output.txt" rel="nofollow noreferrer">output</a>.</p>
  
  <pre><code>public static List&lt;String&gt; findPathToNode(Node rootNode, Point toFind) {
      // @ToDo Implement this routine
      List&lt;String&gt; nodeList = new ArrayList&lt;&gt;();
      if(toFind.getX() &lt; rootNode.getWidth() &amp;&amp; toFind.getY() &lt;rootNode.getWidth()){
        return getPath(rootNode, toFind, nodeList);
      }
     return nodeList;
    }
  
    //Recursive function to loop through all nodes of tree and return empty LinkedList
    // if point not found or NOT Empty with the path to the point, if point is found
    private static List &lt;String&gt; getPath(Node root, Point p, List&lt;String&gt; result) {
      if(p.getX() &gt;-1 &amp;&amp; p.getY() &gt;-1) {
        if (root != null) {
          result.add(root.getId());
          List&lt;Node&gt; childNodes = root.getChildren();
          if (childNodes != null &amp;&amp; !childNodes.isEmpty()) {
            Node child = null;
            for (Node node : childNodes) {
  
               (isLeftBoundCondtionMet(node,p) &amp;&amp; isTopBoundCondtionMet(node,p)) {
                child = node;
              }
            }
            getPath(child, p, result);
          }
        }
      }
      return result;
    }
  
    public static Boolean isLeftBoundCondtionMet(Node root, Point p) {
      return root.getLeft() &lt;= p.getX() &amp;&amp; (p.getX() &lt; (root.getLeft() + root.getWidth()));
    }
  
    public static Boolean isTopBoundCondtionMet(Node root, Point p) {
      return root.getTop() &lt;= p.getY() &amp;&amp; (p.getY() &lt; (root.getTop() + root.getHeight()));
    }
  </code></pre>
  
  <p>It gives me the following error</p>
  
  <pre><code>org.junit.ComparisonFailure: Error in output. Unexpected path for point: java.awt.Point[x=32,y=3] 
  Expected :node/node-1/node-1-6/node-1-6-8/node-1-6-8-4
  Actual   :node/node-1/node-1-6
  </code></pre>