<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _find_directory_upwards(base: str, target: str) -> Optional[str]: """ Walk directories upwards from base, until the root directory is reached. At each step, check if the target directory exist, and return it if found. Return None if the search is unsuccessful. """

    while True:
        step = os.path.join(base, target)
        LOG.debug("Trying with: `%s`", step)
        if os.path.isdir(step):
            return step
        parent_directory = os.path.dirname(base)
        if parent_directory == base:
            # We have reached the root.
            break
        base = parent_directory
    return None