implemented intelligent tree merging for added lines