def get_optional_field_value(data, field_name, pk, fetch_model):
    """Gets the value of a model field if it exists either in serializer data or in the database.
    "Optional" means it's not an issue if the field value is not present.

    If there's no field in data, then model if fetched via function provided and looked up instead.
    Field can be missing in data in case of partial update (PATCH) or in case action allows that some other way.

    Parameters:

    - data #dict: The serializer's data to look up the field in first.
    - field_name #str: The name of the field to look up.
    - pk #object: The value of corresponding entity's PK to fetch model in case there's no field in data.
    - fetch_model #function: A function which is expected to return model instance if executed with its PK as argument.

    Returns: the value of the field if present else #None.
    """
    if field_name in data:
        return data.get(field_name)
    return None if pk is None else getattr(fetch_model(pk), field_name)
