Index: trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/Trie.java
===================================================================
--- trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/Trie.java	(revision 1110)
+++ trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/Trie.java	(revision 1118)
@@ -121,5 +121,5 @@
     /**
      * <p>
-     * Trains the current trie using the given sequence and adds all subsequence of length
+     * Trains the current trie using the given sequence and adds all subsequences of length
      * {@code maxOrder}.
      * </p>
@@ -145,6 +145,7 @@
         }
         int sequenceLength = sequence.size();
-        for (int j = maxOrder - 1; j > 0; j--) {
-            add(sequence.subList(sequenceLength - j, sequenceLength));
+        int startIndex = Math.max(0, sequenceLength - maxOrder + 1);
+        for (int j = startIndex; j < sequenceLength; j++) {
+            add(sequence.subList(j, sequenceLength));
         }
     }
@@ -320,4 +321,47 @@
 
         return contextSuffix;
+    }
+    
+    /**
+     * 
+     */
+    public void process(TrieProcessor<T> processor) {
+        LinkedList<T> context = new LinkedList<T>();
+        
+        for (TrieNode<T> child : rootNode.getChildren()) {
+            if (!process(context, child, processor)) {
+                break;
+            }
+        }
+    }
+
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     * @param context 
+     *
+     * @param child
+     * @param processor
+     */
+    private boolean process(LinkedList<T>    context,
+                            TrieNode<T>      node,
+                            TrieProcessor<T> processor)
+    {
+        context.add(node.getSymbol());
+        
+        TrieProcessor.Result result = processor.process(context, node.getCount());
+        
+        if (result == TrieProcessor.Result.CONTINUE) {
+            for (TrieNode<T> child : node.getChildren()) {
+                if (!process(context, child, processor)) {
+                    break;
+                }
+            }
+        }
+        
+        context.removeLast();
+        
+        return result != TrieProcessor.Result.BREAK;
     }
 
Index: trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/TrieProcessor.java
===================================================================
--- trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/TrieProcessor.java	(revision 1118)
+++ trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/TrieProcessor.java	(revision 1118)
@@ -0,0 +1,40 @@
+//   Copyright 2012 Georg-August-Universität Göttingen, Germany
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+
+package de.ugoe.cs.autoquest.usageprofiles;
+
+import java.util.List;
+
+/**
+ * <p>
+ * TODO comment
+ * </p>
+ * 
+ * @author Patrick Harms
+ */
+public interface TrieProcessor<T> {
+    
+    /**
+     * 
+     */
+    public enum Result {
+        CONTINUE, SKIP_NODE, BREAK
+    }
+
+    /**
+     * 
+     */
+    public Result process(List<T> sequence, int count);
+    
+}
