implementation for suffix tree