Weighted paths: store distance sums instead of edge counts. XOR paths: track XOR values from centroid to each node. Vertex-weighted paths: add node values to distances. The pattern adapts to many properties. You can also use centroid decomposition for nearest marked node queries.
Preprocess distances from centroids to marked nodes, then binary search or check during queries. The core pattern (decompose, process through centroid, recurse) applies to all these variations. Once you understand the structure, adapting it is direct.