code now using the nodesize instead of tree size