def _split_dict(in_dict, key_names, nullable_fields=frozenset()):
    """
    Split a dict into two dicts. Keys in key_names go into the new dict if
    their value is present and not None, allowing for None values if the key
    name is present in the nullable_fields set.
    return (updated original dict, new dict)
    """
    new_dict = {}
    for key_name in key_names:
        if key_name in in_dict:
            val = in_dict.pop(key_name, None)
            if val is not None or val is None and key_name in nullable_fields:
                new_dict[key_name] = val
    return in_dict, new_dict
