Retrieving the Parent Element Path

Function to Retrieve the Parent Element Path

function getParent(myelement) {
 var path = "";
 do {
 var parent =

 myelement.getEntities("hierarchy::HIERARCHIC@LOCAL,targetrole=parent");

 if (parent[0].getProperty("IndexMode") == 1) {
 return (path);
 }
 if (path =="")
 path = parent[0].getProperty("DisplayName");
 else
 path = parent[0].getProperty("DisplayName") + " | "+path;
 myelement = parent[0];
 } while (parent[0].getProperty("IndexMode") != 1);
 return (null);
}