import ipaddress


def one_net(_subnets):
    """
    Get the one IP network that covers all subnets in input or None is subnets are disjoint.
    """
    if len(_subnets) == 0:
        return None

    minimum_length = min([net.prefixlen for net in _subnets])
    while _subnets.count(_subnets[0]) < len(_subnets) and minimum_length > 0:
        # all subnets are not (yet) equal
        _subnets = [net.supernet(new_prefix=minimum_length) for net in _subnets]
        minimum_length -= 1

    # 0.0.0.0/? -> no common subnet
    if _subnets[0].network_address == ipaddress.ip_address(u'0.0.0.0'):
        return None

    return _subnets[0]