Get another table row on the basis of first table Scenario,

I have three table like ,
Table - 1

table_1_id    status
   1          pending
   2          progress
   3


Table - 2 

  table_2_id   status     table_1_id
     1         pending      1
     2         progress     1
     3         pending      2
     4         completed    3


Table -3 

   table_3_id  status      table_2_id
        1      pending        1
        2      pending        2
        3      pending        1
        4      progress       2
        5      completed      3
        6      pending        4


All the table in one to many relation 

I want to write query which cover following scenario

   1. Run the select statement on table_1 , with 'pending' status and given primary key of table_1. 

     1.1 If row any found - then run the second select on table_2, with 'pending' status and the table_1 primary key (which is foreign key in table_2)


       1.1.1 If any row found - then run the third select on table_3 , 
           with pending status and table_2 primary key (which is foreign key in
           table_3), then return the primary key means table_3_id.

       1.1.2 If no row found- then return the primary key of table 2 means table_id_2.

     1.2 If no row found - then return the primary key of first table means table_1_id.

 2. If no row found - then return null
...
IF ( EXISTS ( SELECT * FROM ... WHERE ... ),  -- "If any row found.."
     ( SELECT ... ),   -- "then run .."
     id ),             -- "If no row found, return .."
...