python version of suffix tree substring search