Creating an endgame engine which would save a weaker player a draw if this can be the case

I’ve created a python code

which is an attempt to save a weaker player a draw if this can be the case.

However, for this position: 8/8/2k5/4K3/7p/8/8/8 w - - 0 4
I’m getting the depth 5 without terminating the computation. Can someone fix for me the code from the link above and paste
the fixed solution to pastebin.com ? What is wrong with the output is the flag ‘None’ for this fields:

“moves_to_mate’: None, ‘parent’: None, ‘color’: True, ‘result’: None, ‘processed’: False, ‘sequence’: , ‘up’: False”
Also, I would like to include the sequence which should be fully optimal for both players, B&W.

My desired output:
Depth: 5 - Nodes Searched: 45390001 {‘fen’: ‘8/8/2k5/4K3/7p/8/8/8 w - - 0 4’, ‘moves_to_mate’: 5, ‘parent’: None, ‘color’: True, ‘result’: 0.5, ‘processed’: True, ‘sequence’: [
Kf4
h3

Kg3
Kc5

Kxh3], ‘up’: False}
Elapsed Time:

MOST NOTABLY, I do not want any heuristics material evaluation or otherwise.
I want to create 64^D positions where D is the number of pieces on the board together with
bottom up propagation of moves_to_mate+1 number keeping both players to play fully optimally.

My wrong output:

Elapsed Time: 0h 0m 0.00s
Depth: 1 - Nodes Searched: 7{‘fen’: ‘8/8/2k5/4K3/7p/8/8/8 w - - 0 4’, ‘moves_to_mate’: None, ‘parent’: None, ‘color’: True, ‘result’: None, ‘processed’: False, ‘sequence’: , ‘up’: False}
Elapsed Time: 0h 0m 1.00s
Depth: 2 - Nodes Searched: 61{‘fen’: ‘8/8/2k5/4K3/7p/8/8/8 w - - 0 4’, ‘moves_to_mate’: None, ‘parent’: None, ‘color’: True, ‘result’: None, ‘processed’: False, ‘sequence’: , ‘up’: False}
Elapsed Time: 0h 0m 2.02s
Depth: 3 - Nodes Searched: 503{‘fen’: ‘8/8/2k5/4K3/7p/8/8/8 w - - 0 4’, ‘moves_to_mate’: None, ‘parent’: None, ‘color’: True, ‘result’: None, ‘processed’: False, ‘sequence’: , ‘up’: False}
Elapsed Time: 0h 0m 4.42s
Depth: 4 - Nodes Searched: 4539{‘fen’: ‘8/8/2k5/4K3/7p/8/8/8 w - - 0 4’, ‘moves_to_mate’: None, ‘parent’: None, ‘color’: True, ‘result’: None, ‘processed’: False, ‘sequence’: , ‘up’: False}
Elapsed Time: 0h 1m 43.90s