how to encapsulate a method that implements the following functions
let a = element["a"]["b"]["c"]...["n"]
let a = element["a"]&&element["a"]["b"]&&element["a"]["b"]["c"]&&...&&element["a"]["b"]["c"]...["n"];
let a = checkObject(element["a"]["b"]["c"]...["n"]);
checkObject(){
//
}