What's the best way to tell if an article is in a general category?  Specifically, given a page title, I want to know if that page is (transitively) in Category:Song.  For example, I can get

http://en.wikipedia.org/w/api.php?action=query&prop=categories&titles=bohemian%20Rhapsody&cllimit=50

which gives me (in part)

      <page pageid="41953" ns="0" title="Bohemian Rhapsody">
        <categories>
          <cl ns="14" title="Category:1975 singles" />
          <cl ns="14" title="Category:1976 singles" />
          <cl ns="14" title="Category:1991 singles" />
          <cl ns="14" title="Category:1992 singles" />
          <cl ns="14" title="Category:All articles with unsourced statements" />
          <cl ns="14" title="Category:Articles with hAudio microformats" />
          <cl ns="14" title="Category:Articles with unsourced statements from April 2010" />
          <cl ns="14" title="Category:BRIT Award for British Single" />
          <cl ns="14" title="Category:Christmas number-one singles in the United Kingdom" />
          <cl ns="14" title="Category:Dutch Top 40 number-one singles" />
          <cl ns="14" title="Category:Good articles" />
          <cl ns="14" title="Category:Grammy Hall of Fame Award recipients" />
          <cl ns="14" title="Category:Irish Singles Chart number-one singles" />
          <cl ns="14" title="Category:Music videos directed by Bruce Gowers" />
          <cl ns="14" title="Category:Number-one singles in Australia" />
          <cl ns="14" title="Category:Number-one singles in New Zealand" />
          <cl ns="14" title="Category:Number-one singles in Spain" />
          <cl ns="14" title="Category:Parlophone singles" />
          <cl ns="14" title="Category:Queen (band) songs" />
          <cl ns="14" title="Category:RPM Top Singles number-one singles" />
          <cl ns="14" title="Category:Rock ballads" />
          <cl ns="14" title="Category:Singlechart" />
          <cl ns="14" title="Category:Singlechart usages for Billboardhot100" />
          <cl ns="14" title="Category:Singlechart usages for Dutch100" />
          <cl ns="14" title="Category:Singlechart usages for New Zealand" />
          <cl ns="14" title="Category:Singlechart usages for UK" />
          <cl ns="14" title="Category:Songs written by Freddie Mercury" />
          <cl ns="14" title="Category:UK Singles Chart number-one singles" />
          <cl ns="14" title="Category:Use British English from August 2010" />
          <cl ns="14" title="Category:Use dmy dates from August 2010" />
        </categories>
      </page>
What I really want to know is if the page is in Category:Song.  In fact, it is, because of the category chain: 1975 singles -> 1975 songs -> Songs by year -> Songs, but finding that path involved some intuition about likely paths to explore.  Lacking such intuition, is there any better mechanism in the API other than an exhaustive search through the category tree?


--
Roy Smith
roy@panix.com