Add null check for block during tree gen (with logging)