function BFSTraverse(startNode, endNode) {
var root = startNode,
parent = {},
visited = {},
q = [],
current_node = null;
q.push(startNode);
//Mark the startNode as visited.
visited[startNode] = true;
while(q.length) {
current_node = q.shift();
getAdjacentNodes(current_node+"/").then(function(nodes) {
if(nodes==[]) return;
nodes.forEach(function(node) {
q.push(node);
visited[node] = true;
});
});
}