A Generalized A* Algorithm for Finding Globally Optimal Paths in Weighted Colored Graphs