title: Get nested set ancestor where condition
body: <p>Given a nested set in mysql like this</p>
  
  <pre><code>+-------------+----------------------+-----+-----+------+
  | category_id | name                 | lft | rgt | rank |
  +-------------+----------------------+-----+-----+------+
  |           1 | ELECTRONICS          |   1 |  20 |  99
  |           2 | TELEVISIONS          |   2 |   9 |  50
  |           3 | TUBE                 |   3 |   4 |  25
  |           4 | LCD                  |   5 |   6 |  25
  |           5 | PLASMA               |   7 |   8 |  25
  |           6 | PORTABLE ELECTRONICS |  10 |  19 |  50
  |           7 | MP3 PLAYERS          |  11 |  14 |  25
  |           8 | FLASH                |  12 |  13 |  10
  |           9 | CD PLAYERS           |  15 |  16 |  25
  |          10 | 2 WAY RADIOS         |  17 |  18 |  20
  </code></pre>
  
  <p>How can I get an ancestor for e.g: "Flash" where condition rank is >=50 AND &lt;= 99 LIMIT 1 sorted by lft DESC. 
  so the result will be</p>
  
  <pre><code>+-------------+----------------------+-----+-----+------+
  | category_id | name                 | lft | rgt | rank |
  +-------------+----------------------+-----+-----+------+
  |           6 | PORTABLE ELECTRONICS |  10 |  19 |  50
  </code></pre>
  
  <p>for visualization refer to this link
  <a href="http://mikehillyer.com/media//categories.png" rel="nofollow">http://mikehillyer.com/media//categories.png</a></p>