Full MTree grammar implementation

(not in-depth bug checked. should be fine)