Opinion by
Judge Menoer,In Dwely v. Tanner, 189 Pa. Superior Ct. 635, 151 A. 2d 665 (1959), it was decided that the court below *41properly directed a township building inspector to issue a plumbing permit. Dively was the owner of approximately forty acres of land in Ohio Township, Allegheny County, and was using approximately five acres of this land for the operation of a house-trailer camp. In December, 1967, Builders Enterprises, Inc. (Builders) acquired Dively’s forty acres of land and subsequently made application for a zoning certificate for a nonconforming use so that it might expand the house-trailer camp over the remaining thirty-five acres of land purchased from Dively. The zoning inspector refused the nonconforming use certificate as to all but the approximately five acres of the property in current use as a trailer camp. On appeal the Zoning Hearing Board of Ohio Township affirmed the zoning inspector’s decision and Builders then appealed to the Court of Common Pleas of Allegheny County. That court reversed the Zoning Hearing Board and ordered the necessary permits to be granted. Its decision was based on the belief that Dively v. Tanner, supra, decided that a nonconforming use existed as to the entire forty-acre tract and was res judicata on this issue. We find the lower court to be in error in this regard and must therefore reverse.
Under the doctrine of res judicata, a judgment is conclusive as between the parties and their privies in respect to every fact which could properly have been considered in reaching the determination and in respect to all points of law relating directly to the cause of action and affecting the subject matter before the court. Wallace’s Estate, 316 Pa. 148, 174 A. 397 (1934). As stated in Cameron Bank v. Aleppo Twp., 338 Pa. 300, 304, 13 A. 2d 40, 41 (1940) : “To constitute res judicata there must be: (1) Identity in the thing sued for: (2) identity of the cause of action; (3) identity of persons and parties to the action; (4) identity of the quality in the persons for or against whom the claim is made.” Stevenson v. Silverman, 417 Pa. 187, 208 A. 2d 786, *42cert. den. 86 S. Ct. 76, 382 U.S. 833, 15 L. Ed. 2d 76 (1965). The essential inquiry is whether the ultimate and controlling issues have been decided in. a prior proceeding in which the present parties had an opportunity. to appear and assert their rights. Callery v. Blythe Township Municipal Authority, 432 Pa. 307, 243 A. 2d 385 (1968).
From these criteria it must be concluded that the rule of res judicata is entirely irrelevant here. When the causes of action in the first and second actions are. distinct, or, even though related, are not. so closely related that matters essential to recovery in the second action have been determined in the first action, the doer trine of res judicata does not apply. Likewise, before, the doctrine may be applied, there must be an identity: of the persons or parties and an identity of quality in - the persons for or against whom the claim is made. Helmig v. Rockwell Mfg. Co., 389 Pa. 21, 131 A. 2d 622 (1957), cert. den. 78 S. Ct. 46, 355 U.S, 832, 2 L. Ed. 2d 44, reh. den. 78 S. Ct. 146, 355 U.S. 885, 2 L. Ed. 2d 115; Melcher v. Pennsylvania Threshermen and. Farmers’ Mutual Casualty Insurance Company, 389 Pa. 125, 132 A. 2d 190 (1957).
In Dively v. Tanner, supra, an action was brought in mandamus to require Herbert Tanner, as township plumbing inspector, to issue a plumbing permit with respect to one building located on the five acres being used as a trailer camp. The court was confronted with the question of whether Dively had established a nonconforming use as to the five-acre plot prior to the enactment of the applicable zoning ordinance. The parties did not litigate, nor was it necessary for the court to determine, whether a nonconforming use existed as to the entire forty-acre tract. .
As was noted in Haefele v. Davis, 399 Pa. 504, 508, 160 A. 2d 711, 713 (1960), the Court citing Wright v. Weber, 17 Pa. Superior Ct. 451, 457 (1901): “‘. ... The *43conclusive effect of a judicial decision cannot be extended by argument or implication to matters not actually heard and determined, nor to collateral questions which arise but do not become part of the case. . . .’ ‘ . [A] former judgment is not conclusive of anything which was not directly decided by it, or was not material to the decision. Before such effect can be given to it in another suit, it should appear either from the record, or aliunde, that it must have rested on the precise question which it is sought again to agitate. 99 9 99
Judge Soffel,, in her opinion, supporting her order which was affirmed in Dwely, stated that “the trailer camp was completed — with the exception of certain plumbing”. This, when coupled with her thirteenth finding of fact which reads as follows: “In June of 1953, the plaintiff contracted for the preparation of a plan of residential lots on part of the same tract involved for use as a trailer camp” (emphasis supplied), clearly establishes that Judge Soffel did not determine the entire forty-acre tract as a nonconforming use but rather that only “part of the same tract [was] involved for use as a trailer camp”.
Accordingly, we hold that it was error for the lower court to. have ruled that Dively v. Tanner, supra, was in fact res judicata as to whether the entire forty-acre tract here involved was a nonconforming use for trailer camp purposes.
Under the zoning ordinance passed by Ohio Township, as amended, the forty-acre tract owned by Builders was classified into two districts, one being R-2 residential and the other R-4 medium density. The five-acre part of Builders’ property being used as a trailer camp is within the R-4 district. A mobile home park is an accessory use in the R-4 district but not one of the permitted uses in the R-2 district. Therefore, it would be necessary, under the provisions of the ordinance, for *44Builders, before it could use its entire premises for a trailer camp, to secure a special exception for that portion .of the property lying within the R-4 area and a variance for that portion lying within the R-2 area.' The lower court having concluded that the entire forty acres, had been determined to be a nonconforming usé by the decision of Dively v. Tanner, supra, ruled that under Article IX, Section 5 of the amending zoning ordinance, enacted May 15,1968, the zoning inspector had the duty to issue a certificate for a lawful nonconforming use. Since Dively v. Tanner, supra, did not. make such a determination as to the entire forty-acre tract, the lower court erred in ordering the. issuance of a zoning certificate. Builders must seek a variance for the expansion of its nonconforming use within the R-2 area and a special exception as to that part, of its. property within the R-4 area. See William Chersky Joint-Enterprises v. Board of Adjustment, 426 Pa. 33, 231 A. 2d 757 (1967); Walter v. Philadelphia Zoning Board, of Adjustment, 437 Pa. 277, 263 A. 2d. 123 (4970). Variances or special exceptions are permis-. sions issued as a result of a zoning proceeding' and in the instant case Builders must seek such permissions; for ..an expansion of its nonconforming trailer camp.
The, lower court held a hearing and received additional testimony and therefore the test is whethér the court abused its discretion or committed añ error of law. Richman v. Zoning Board of Adjustment,. 391 Pa. 254, 137 A. 2d 280 (1958). We find, for the reasons set forth herein, that the lower court was in error in: directing that the certificates of lawful nonconforming use be granted to Builders. - '
Order reversed.