Checking the existence of a pattern in a given prefix
Recall that in a suffix tree for $T$, each leaf corresponds to a suffix of $T$, and is labeled by its position. Furthermore, each internal vertex corresponds to a common prefix of some suffixes of $T$. We label each internal vertex with the minimal position of a suffix covered by it.
Construct a suffix tree for $T$, and augment it by labeling the internal vertices as described above. Given a pattern $P$, traverse the suffix tree to find the vertex corresponding to $P$ (it might correspond to some extension of $P$), and check whether the minimal position written there implies that $P$ occurs before position $k$.