title: Converting a Breadth First Search to Depth first Search in Java
body: <p>its been a long time since I touched Java so this may seem like an odd question. Currently have this Breadth First Search code I found here on StackOverflow, I have it modified on my end but I'll post the original code here.</p>
  
  <pre><code>public List&lt;Node&gt; getDirections(Node start, Node finish){
      List&lt;Node&gt; directions = new LinkedList&lt;Node&gt;();
      Queue&lt;Node&gt; q = new LinkedList&lt;Node&gt;();
      Node current = start;
      q.add(current);
      while(!q.isEmpty()){
          current = q.remove();
          directions.add(current);
          if (current.equals(finish)){
              break;
          }else{
              for(Node node : current.getOutNodes()){
                  if(!q.contains(node)){
                          q.add(node);
                  }
              }
          }
      }
      if (!current.equals(finish)){
          System.out.println("can't reach destination");
  }
  return directions;
  }
  </code></pre>
  
  <p>I'm aware of other depth first search algorithms out there, but I was also told its possible to convert breadth first search to depth first search easily, and I would understand it better if it was done to this code instead of 2 totally different codes. </p>
  
  <p>How can I change this to be a Depth First Search?</p>