LPS-48280 Extract tree code into modules