Reg_block.get_reg_by_name returns unexpected null

Hi All,
Consider the following code snippet

// Called from body() task with last arg. as config_h.reg_block.XMT_WR.get_name()
task write_data_axi(input integer my_addr, input bit [31:0] data_in, string name); 
   uvm_reg  reg_h;

  `uvm_info("write_dat_axi",$sformatf("Called with i/p arg. as %0s",name),UVM_LOW)
   .........
  // Assume that config_h.reg_block is non-null
  reg_h = config_h.reg_block.get_reg_by_name(name);
   if(  reg_h != null )  begin
     if(!reg_h.predict(data_in)) 
        `uvm_error(get_name(),$sformatf("Prediction Unsucessful"))
   end      
   else      
      `uvm_fatal(get_type_name(),$sformatf("Unable to find register: %0s",name))

endtask

The output when write_data_axi is called

UVM_INFO … [write_dat_axi] Called with i/p arg. as XMT_WR
UVM_FATAL … [b2b_isr_seq] Unable to find register: XMT_WR

It seems that API ‘get_reg_by_name’ returns null due to which the UVM_FATAL msg is observed

If I change the code to

if( config_h.reg_block.get_reg_by_name(name) != null ) begin
  reg_h = config_h.reg_block.get_reg_by_name(name);
  if(!reg_h.predict(data_in)) `uvm_error(get_name(),$sformatf("Prediction Unsucessful"))
end      
else      
 `uvm_fatal(get_type_name(),$sformatf("Unable to find register: %0s",name))

I don’t encounter the UVM_FATAL message.
Any suggestions on what’s the issue with the 1st code ?

Thanks in Advance