HOW GET BPMN Get the previous steps

hi
i want get the previous steps .i want get click step4 show list from name and id activitiy step1,2,3 or console.log
and with id step4 get the previous steps
Untitled11

You can find connected elements via the outgoing & incoming properties of any element.

const eventBus = modeler.get("eventBus");

eventBus.on("element.click", function (event) {
  const { element } = event;

  console.log("element clicked:", element);
  console.log("element id + name:", element.id, element.businessObject.name);
  console.log("incoming (before):", element.incoming);
  console.log("outgoing (after):", element.outgoing);
});

This way you can go along the chain and potentially find those elements.

Source: element incoming outgoing - CodeSandbox