getConnectedNodes(nodeId, direction) {
    const nodeList = [];
    if (this.body.nodes[nodeId] !== undefined) {
      const node = this.body.nodes[nodeId];
      const nodeObj = {}; // used to quickly check if node already exists
      for (let i = 0; i < node.edges.length; i++) {
        const edge = node.edges[i];
        if (direction !== "to" && edge.toId == node.id) {
          // these are double equals since ids can be numeric or string
          if (nodeObj[edge.fromId] === undefined) {
            nodeList.push(edge.fromId);
            nodeObj[edge.fromId] = true;
          }
        } else if (direction !== "from" && edge.fromId == node.id) {
          // these are double equals since ids can be numeric or string
          if (nodeObj[edge.toId] === undefined) {
            nodeList.push(edge.toId);
            nodeObj[edge.toId] = true;
          }
        }
      }
    }
    return nodeList;
  }
Get the Ids of nodes connected to this node.
@param {Node.id} nodeId
@param {'to'|'from'|undefined} direction values 'from' and 'to' select respectively parent and child nodes only.
                                         Any other value returns both parent and child nodes.
@returns {Array}