Shouldn't numParents in the for loop be numChildren?