fix warnings if element with key doesn't exists - ref #7864 - fixes #788...

...7

ref #7864 
fixes #7887

cc @PVince81 @DeepDiver1975 @icewind1991