def get_wildcard_path(path):
    """Replace namespaces with wildcard

    Change "|foo:bar|foo:nah" into "|*:foo|*nah"

    """
    wildcarded = list()
    for part in path.split("|"):
        namespaces, leaf = ([""] + part.rsplit(":", 1))[-2:]
        w = "*:" * len(namespaces.split(":")) + leaf
        wildcarded.append(w if leaf else "")

    return "|".join(wildcarded)