A lot of the code in the current implementation uses if-else chains but the python match/case statement (introduced in python 3.10) would fit better.
Task: Rewrite the code to use match statement - for example in the many cases where we have code that is conditional on the type such as:
if type(foo) == Bar:
...
elseif type()....
...