def field_to_dict(fields):
    """
    Build dictionnary which dependancy for each field related to "root"

        fields = ["toto", "toto__tata", "titi__tutu"]
        dico = {
            "toto": {
                EMPTY_DICT,
                "tata": EMPTY_DICT
                },
            "titi" : {
                "tutu": EMPTY_DICT
            }
        }

    EMPTY_DICT is useful because we don't lose field
    without it dico["toto"] would only contains "tata"

    inspired from django.db.models.sql.add_select_related
    """
    field_dict = {}
    for field in fields:
        d_tmp = field_dict
        for part in field.split(LOOKUP_SEP)[:-1]:
            d_tmp = d_tmp.setdefault(part, {})
        d_tmp = d_tmp.setdefault(
            field.split(LOOKUP_SEP)[-1],
            deepcopy(EMPTY_DICT)
        ).update(deepcopy(EMPTY_DICT))
    return field_dict
Build dictionnary which dependancy for each field related to "root"

        fields = ["toto", "toto__tata", "titi__tutu"]
        dico = {
            "toto": {
                EMPTY_DICT,
                "tata": EMPTY_DICT
                },
            "titi" : {
                "tutu": EMPTY_DICT
            }
        }

    EMPTY_DICT is useful because we don't lose field
    without it dico["toto"] would only contains "tata"

    inspired from django.db.models.sql.add_select_related