Implemented tree drawing algorithm