def compare(left: Optional[L], right: Optional[R]) -> 'Comparison[L, R]':
        """
        Calculate the comparison of two entities.

        | left      | right     | Return Type             |
        |===========|===========|=========================|
        | file      | file      | FileComparison          |
        | file      | directory | FileDirectoryComparison |
        | file      | None      | FileComparison          |
        | directory | file      | DirectoryFileComparison |
        | directory | directory | DirectoryComparison     |
        | directory | None      | DirectoryComparison     |
        | None      | file      | FileComparison          |
        | None      | directory | DirectoryComparison     |
        | None      | None      | TypeError               |

        :param left: The left side or "before" entity.
        :param right: The right side or "after" entity.
        :return: See table above.
        """
        if isinstance(left, File) and isinstance(right, Directory):
            return FileDirectoryComparison(left, right)

        if isinstance(left, Directory) and isinstance(right, File):
            return DirectoryFileComparison(left, right)

        if isinstance(left, File) or isinstance(right, File):
            return FileComparison(left, right)

        if isinstance(left, Directory) or isinstance(right, Directory):
            return DirectoryComparison(left, right)

        raise TypeError(f'Cannot compare entities: {left}, {right}')