Optimized hasChildren