correcting bug in recursive tree append