from pathlib import Path


def _get_timestamped_path(
        parent_path: Path,
        middle_path,
        child_path='',
        timestamp='',
        create=True,
):
    """
    Creates a path to a directory by the following pattern:
     parent_path / middle_path / [child_path] / [timestamp]
    :param parent_path:
    :param middle_path:
    :param child_path:
    :param timestamp
    :param create: if True (default) will create all the directories in the path
    :return: pathlib.Path object
    """
    dir_path = parent_path / middle_path / child_path / timestamp

    if create:
        dir_path.mkdir(parents=True, exist_ok=True)

    return dir_path