def repack(data):
    """
    Recreate a nested object structure from a flat dictionary.

    Example:
        repack({"p.x": 1}) -> {"p": {"x": 1}}
    """
    result = dict()

    for key, value in data.items():
        steps = key.split(".")

        pointer = result
        while len(steps) > 1:
            if steps[0] not in pointer:
                pointer[steps[0]] = dict()
            pointer = pointer[steps.pop(0)]
        pointer[steps[0]] = value

    return result