1. A method for processing a query, comprising: receiving, with a computer including a processor, the query, wherein the query is formed by one or more paths, wherein each path includes one or more steps, and wherein the query uses a descendant axis in one or more steps; receiving a hierarchical document including one or more document nodes, wherein the hierarchical document includes recursive nodes that are identical and have ancestor, descendant relationships; and while processing the query and traversing the hierarchical document, constructing a structure, wherein the structure includes query nodes, and wherein each of the query nodes includes a next step in a path of the query, a level for a next step instance, a parent step instance identifier of a next step instance, and a matched step instance identifier when a match is found; constructing one or more extraction entries by traversing the structure, wherein each of the one or more extraction entries includes a step instance match candidate identifying a document node and a step instance ancestor path for the document node; and constructing one or more tuples using the one or more extraction entries by associating the step instance match candidate from one of the one or more extraction entries with the step instance match candidate from at least another of the one or more extraction entries.