tree manipulation debugged, tested and working