title: MySQL: How to find leaves in specific node
body: <p>I know this kind questions has been posted here many times, for exmaple: <a href="https://stackoverflow.com/questions/10413261/how-to-get-all-leaves-of-given-node-tree-has-only-id-parent">Java way</a> </p>
  
  <p>I have huge amount of data (150k+) in standard tree pattern (<code>id</code>, <code>parent_id</code>, <code>some_data</code>)</p>
  
  <p><strong>Question:</strong> How to get leaves for given node_id?</p>
  
  <p>Table structure:</p>
  
  <pre><code>CREATE TABLE `DATA_TREE` (
    `ID` int(11) NOT NULL,
    `PARENT_ID` int(11) NOT NULL,
    `DATA` varchar(45) DEFAULT NULL,
    PRIMARY KEY (`ID`),
    UNIQUE KEY `ID_UNIQUE` (`ID`),
    KEY `fk_DATA_TREE_1_idx` (`PARENT_ID`),
    CONSTRAINT `fk_DATA_TREE_1` FOREIGN KEY (`PARENT_ID`) REFERENCES `DATA_TREE` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
  ) ENGINE=InnoDB DEFAULT CHARSET=utf
  </code></pre>
  
  <p>Database: <code>MySQL 5.1.61</code></p>