Uniform Cost Search Code In Python