title: Finding a common node with key between two different BinarySearchTrees
body: <p>I am currently trying to write methods that checks all the nodes in two different Binary Search trees and find nodes with common keys between the two trees. (i.e. trying to find a node from tree 1 and a node from tree 2 that contains the same keys. If a common node is found, the method returns true, otherwise it returns false. The second tree is stored in a different object than tree 1, called <code>GraphicalObject</code>. And the key is in the form of coordinates and size comparason is done using column order.</p>
  
  <p>I have written the following code, but wondering if there is anything wrong with it or if there is anything I could improve up on?</p>
  
  <p>1) A method that checks if a node from tree 1 is the same as every node in tree 2 using recursive calls. the <code>compareTo</code> method is defined else where.</p>
  
  <pre><code>public boolean findPixel(BinaryNode node1, BinaryNode node2, GraphicalObject gobj) {
      //Creating the final coordinate key by altering the original key in nodes of tree 2.
      int xCor = node2.getData().getLocation().xCoord() + gobj.getOffset().xCoord() - graphicPos.xCoord();
      int yCor = node2.getData().getLocation().yCoord() + gobj.getOffset().yCoord() - graphicPos.yCoord();
      Location newLoc = new Location(xCor, yCor); //Creates the final key to be checked up on
      if(node1.getData().getLocation().compareTo(newLoc) == 0) { //If keys are the same
          return true;
      } else {
          if(node1.getData().getLocation().compareTo(newLoc) == -1) { //if key from node 1 is smaller than key from node 2.
              node2 = node2.getLeft();
              findPixel(node1, node2, gobj);
          } else {
              node2 = node2.getRight();
              findPixel(node1, node2, gobj);
          }
      }
      return false; 
  }
  </code></pre>
  
  <p>2) A method that uses <code>findPixel</code> method to check every node in tree 1 and compare them to every node in tree 2, using inorder traversal.</p>
  
  <pre><code>private boolean findCommonNode(BinaryNode node1, BinaryNode node2, GraphicalObject gobj) {
      if(node1 != null) {
          findCommonNode(node1.getLeft(), node2, gobj);
          return findPixel(node1, node2, gobj);
          findCommonNode(node1.getRight(), node2, gobj);
      }
  }
  </code></pre>
  
  <p>3) method that returns true if common node between the two trees is found, or false otherwise.</p>
  
  <pre><code>public boolean intersects(GraphicalObject gobj){
      BinaryNode tempNode = newTree.getRoot();
      BinaryNode tempNode2 = gobj.getTree().getRoot();
      if (findCommonNode(tempNode, tempNode2, gobj) == true) {
          return true;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>Is there anything wrong with this code? Or is there anything I could do to make it better or run more efficiently?</p>