Using the Sadakane Compressed Suffix Tree to Solve the All-Pairs Suffix-Prefix Problem
Figure 2
The text position for each leaf which has a terminal edge will be added to the list of the closest ancestor which does not have a terminal edge pointing to it.