public static SuffixTree create(Text text) {
    SuffixTree tree = new SuffixTree(text);
    Suffix active = new Suffix(tree.root, 0, -1);
    for (int i = 0; i < text.length(); i++) {
      tree.addPrefix(active, i);
    }
    return tree;
  }
@Test
  public void test() {
    String text = this.data + "$";
    StringSuffixTree tree = StringSuffixTree.create(text);

    assertThat(tree.getNumberOfLeafs()).as("number of leaves").isEqualTo(text.length());
    assertThat(tree.getNumberOfInnerNodes()).as("number of inner nodes").isLessThan(text.length() - 1);
    assertThat(tree.getNumberOfEdges()).as("number of edges").isEqualTo(tree.getNumberOfInnerNodes() + tree.getNumberOfLeafs());

    for (int beginIndex = 0; beginIndex < text.length(); beginIndex++) {
      for (int endIndex = beginIndex + 1; endIndex < text.length() + 1; endIndex++) {
        String substring = text.substring(beginIndex, endIndex);
        assertThat(tree.indexOf(substring)).as("index of " + substring + " in " + text).isEqualTo(text.indexOf(substring));
      }
    }
  }