title: Wordpress function to get top level category of a post?
body: <p>Hi I am trying to find the top most category of a post.  I tried finding any WP builtin functions but failed.</p>
  
  <p>For example I have categories like this.</p>
  
  <pre><code>Parent
       sub-1
            sub-2
  </code></pre>
  
  <p>And I have a post in sub-2.  So with the ID of sub-2, I am trying to find the ID of top most category which is named "Parent" in this example.</p>