def search_codetree_minfreq(word,codetree,minfreq=1,minlen=1,fullwords=False):
    """ Finds in codetree (symbol per node) longest possible left substring of word,
        at least of len=minlen and at least of freq=minfreq;
        returns frequency and substring length or None if not found
    """
    ret = None
    for pos in range(len(word)):
        s = word[pos]
        if s not in codetree:
            break
        else:
            if codetree[s][0]<minfreq:
                break
            if fullwords:
                if pos==len(word)-1:
                    ret = codetree[s][0],pos+1
            else:
                if pos+1>=minlen or pos==len(word)-1:
                    ret = codetree[s][0],pos+1
            codetree = codetree[s][1]
    return ret