Populate second node reference field based on what first node reference field is selected I have 2 content types. "ABC" content type and "DEF" content type.  In "DEF" content type i give reference to "ABC" node reference.

I am building another content type called "XYZ" where i give node reference to "ABC" and along with it i give node reference to "DEF" content type. 

My problem is that i need to filter out the "DEF"(node reference to "DEF") drop down based on what "ABC" is selected from previous "ABC" drop down. 

How to achieve this.

Any help is appreciated.
You can use custom coding to achieve this, here the idea


Add a script to call a ajax call back on change your first node reference select list.
Define the menu callback in your custom module.
On change of first select list, get the selected node id and pass to above defined function
Write the query to get depended node ids
Output it as 

$options .= "nid." ".$selected." >".$data->node_title."";
     echo $options;
In your jquery ajax success part, add it eg: 
success: function(data) {
f(data){$('#your-second-noderefernced-field').html(data);}


Hope this idea help you to proceed on