Below is the code which I'm willing to compress:
$somefield = 0;
if ($config->get('var1.one') && is_numeric($config->get('var1.one'))) {
$somefield = $this->entityManager->getStorage('node')->load($config->get('var1.one'));
}
$different_field = 0;
if ($config->get('var2.two') && is_numeric($config->get('var2.two'))) {
$different_field = $this->entityManager->getStorage('node')->load($config->get('var2.two'));
}