Implement suffix tree algorithm