Improve suffix tree implementation to make sure it runs in O(n^2) for both JDK 6 and 7 because of the substring implementation change.