Implmented print function, started tree construction