title: Easy way to find Subtree in a Tree
body: <p>I'm writing some code that uses a Tree (a regular tree that can have an unlimited number of nodes, but no crossover, i.e. two parent nodes will not point the the same child node).  Anyway, two things:</p>
  
  <p>1) Are there any well-known algorithms for finding a sub-tree within a tree.</p>
  
  <p>2) Are there any Java libraries (or any libraries for that matter) that already implement this algorithm?  Even if there are none, can anyone recommend any good general purpose Java tree library?</p>
  
  <p>I want to use these trees for holding data in a tree format, not for their searching capabilities.</p>
  
  <p>To expand a bit: I'm using the tree as part of game to keep a history of what happens when a certain events happen.  For example, an A can hit a B which can hit two A's which can hit another two A's etc.</p>
  
  <p>That would look something like:</p>
  
  <pre><code>    A
      |
      B
     /
    A 
   / \  
  A   A
     / \
    A   A
  </code></pre>
  
  <p>Of course there's more than just A and B.  What I want to do is (for an achievement system) is be able to tell when, say an A has hit two A's:</p>
  
  <pre><code>  A
   / \
  A   A
  </code></pre>
  
  <p>I want to be able to easily know if the first tree contains that subtree.  And I don't want to have to write all the code for doing so if I don't have to :)</p>