title: Implementing a dictionary using an AVL Tree findAll() method
body: <p>I am trying to implement a Dictionary ADT using an AVL tree and am having trouble with the findAll(K key) method. I know how to do this using the entries() method and iterating through each one but I need my method to be O(logn) so I need to use the treeSearch(key, position) method. 
  My Dictionary looks like this:
      public class FoodDictionary, V> implements Dictionary {</p>
  
  <pre><code>/** List in which all the entries are stored. */
  private AVLTree&lt;K,V&gt; dictionary;
  
  /** Create a new, empty unordered Dictionary. */
  public FoodDictionary() {
      dictionary = new AVLTree&lt;K,V&gt;();
  }
  
  /**
   * FOR TESTING PURPOSES ONLY! 
   */
  protected AVLTree&lt;K,V&gt; getTree(){
      return dictionary;
  }
  
  /**
   * Returns an iterable object of all the entries in the tree
   * @returns the tree, an iterable object
   */
  public Iterable&lt;Entry&lt;K, V&gt;&gt; entries() {
      return dictionary;
  }
  
  /**
   * Returns the first entry found with the matching
   * key.
   * @param key the key to be found
   * @return the first entry found 
   */
  public Entry&lt;K, V&gt; find(K key) {
      return dictionary.find(key).element();
  }
  
  /**
   * Returns all of the entries with the given key
   * 
   * @param key the key to be found 
   * @return an iterable object containing all the 
   * entries found with the given key
   */
  public Iterable&lt;Entry&lt;K, V&gt;&gt; findAll(K key) {
      PLSequence&lt;Entry&lt;K,V&gt;&gt; list = new PLSequence&lt;Entry&lt;K,V&gt;&gt;();
      for(Entry&lt;K,V&gt; entry : entries()){
          if(entry.getKey().equals(key)){
              list.addLast(entry);
          }
      }
      return list;
  }
  
  
  /**
   * Returns the size of the dictionary
   * @return the size of the dictionary
   */
  @Override
  public int size() {
      return dictionary.size();
  }
  
  /**
   * Returns whether or not the dictionary 
   * is empty
   * @return true if the dictionary is empty
   *          false if the dictionary is not empty
   */
  @Override
  public boolean isEmpty() {
      return dictionary.isEmpty();
  }
  
  /**
   * Adds an entry to this dictionary
   * @param key they key of the new entry
   * @param value the value of the new entry
   * @return the new entry added to the dictionary
   * @throws InvalidKeyException if the given key was not valid
   */
  @Override
  public Entry&lt;K, V&gt; insert(K key, V value) throws InvalidKeyException {
      return dictionary.add(key, value);
  }
  
  /**
   * Removes an entry from this dictionary
   * @param e the entry to be removed
   * @return the entry removed or null if it was not found
   * @throws InvalidEntryException if the entry input was invalid
   */
  @Override
  public Entry&lt;K, V&gt; remove(Entry&lt;K, V&gt; e) throws InvalidEntryException {
      return dictionary.remove(e.getKey());
  }
  }
  </code></pre>
  
  <p>Currently, like I said, my findAll() is using the entries() to iterate through but I need to somehow use the treeSearch() 
  Can anyone help me with this implementation? I do not have a lot of time to complete it and I am completely lost on ideas. 
  Any help is appreciated!</p>