`if hasattr(module, 'has_children', False)` would be more correct.