Uniform Cost Search Algorithm In Python