In this case, specifically, I am not sure what the guy could have done to prevent the child from entering. Clearly he was unattended by the parent, and trespassing on another person's private property. If the parent pursues a lawsuit, the homeowner should consider turning the parent in to child protective services, for her negligence in supervising her child.
As a general rule, I am a friendly neighbor but not
too friendly. And in cases where neighbors have kids, I make it quite clear that I do not want them on my property at any time. I don't do Trick-or-Treat, I don't want any ball playing that just happens to spill over onto my property, and I don't want kids cutting through my backyard or over my lawn. If kids are going to put themselves in any danger of being injured, they need to do so on their parents' property, not mine.
Before you hand out candy or allow ball-playing on your property, understand that if a kid gets hurt, you're going to find yourself in big trouble. At the very least, your homeowners insurance premiums will get jacked up.