If a railroad is laid out across a public way, the county commissioners, or the department of highways in the case of a state highway, upon the application of the railroad corporation, or of the board of aldermen of the city or selectmen of the town where the crossing is situated, after notice to all persons interested and a hearing, may adjudge that public necessity requires the crossing at the same level, and may, if the department also consents in writing to such crossing at the same level, make a decree specially to authorize and require the corporation so to construct its railroad, in such manner as shall be prescribed in the decree, and the commissioners, or the department of public works in the case of a state highway, may modify such decree or may revoke it at any time before the construction of the railroad at such crossing.
Mass. Gen. Laws ch. 160, § 102