from typing import Dict
from typing import Any
import operator
from functools import reduce


def from_dot_notation(field: str, obj: Dict[Any, Any]) -> Any:
    """ Method to retrieve a value from the configuration using dot-notation.
    Dot-notation means nested fields can be accessed by concatenating all the parents
    and the key with a "." (e.g. db.driver.name).

    Args:
        field: The field (in dot-notation) to access
        obj: The object to access using dot-notation

    Returns:
        value: The value at the specified key, in the specified obj
    """

    # Split the key into separate element
    keys = field.split(".")

    def retrievePart(obj, key):
        # Return an empty dict when the key doesn't exist
        if key not in obj:
            obj[key] = {}
        return operator.getitem(obj, key)

    # Use reduce to traverse the dictionary and retrieve the required keys
    value = reduce(retrievePart, keys, obj)
    return value