It would be simpler to just add a `features[i].features` check in this condition.