Implements the part of searching for common suffixes