We have two aims in this paper. First, we generalize the well-known theory of matrix-geometric methods of Neuts to more complicated Markov chains. Second, we use the theory to solve a last-come-first-served queue with a generalized preemptive resume (LCFS-GPR) discipline. The structure of the Markov chain considered in this paper is one in which one of the variables can take values in a countable set, which is arranged in the form of a tree. The other variable takes values from a finite set. Each node of the tree can branch out into d other nodes. The steady-state solution of this Markov chain has a matrix product-form, which can be expressed as a function of d matrices Rl,· ··, Rd. We then use this theory to solve a multiclass LCFS-GPR queue, in which the service times have PH-distributions and arrivals are according to the Markov modulated Poisson process. In this discipline, when a customer's service is preempted in phase j (due to a new arrival), the resumption of service at a later time could take place in a phase which depends on j. We also obtain a closed form solution for the stationary distribution of an LCFS-GPR queue when the arrivals are Poisson. This result generalizes the known result on a LCFS preemptive resume queue, which can be obtained from Kelly's symmetric queue.