1. A method for searching a document for a query pattern, the method comprising: storing a plurality of streams each including a linear sequence of nodes, each stream associated with nodes having a common label in a data tree of the document; searching for a query pattern in the streams by executing a plurality of threads, where each of two or more of the threads is used to search different sub-streams of the plurality of streams, wherein each of the different sub-streams in each stream is uniquely correlated with one or more disjoint sub-trees of a partition of the tree into a plurality of sub-trees; and generating a result of the query pattern search using at least one of the threads.