In this paper, the optimality proof of Ziv–Lempel coding is re-studied, and a more general compression optimality theorem is derived. In particular, the property of quasi-distinct parsing is defined. This property allows infinitely many repetitions of phrases in the parsing as long as the total number of repetitions is o(n/logn), where n is length of the parsed string. The quasi-distinct parsing property is weaker than distinct parsing used in the original proof which does not allow repetitions of phrases in the parsing. Yet we show that the theorem holds with this weaker property as well. This provides a better understanding of the optimality proof of Ziv–Lempel coding, together with a new tool for proving optimality of other compression schemes which is applicable for a much wider family of codes. To demonstrate the possible use of this generalization, a new coding method–the Arithmetic Progression Tree coding (APT)–is presented. This new coding method is based on a principle that is very different from Ziv–Lempel’s coding. Nevertheless, the APT coding is analyzed in this paper and using the generalized theorem shown to be asymptotically optimal up to a constant factor,11Of course, a constant factor for a compression method may indicate that the method is practically useless. In the APT proof presented in this paper the constant is less than 10, however, this constant may be only a byproduct of an inefficiency of the proof. The true constant may be much less. if the APT quasi-distinctness hypothesis holds. An empirical evidence that this hypothesis holds is also given.