added a guard for computing subtree cost - no longer require a list of size n + 1