FXOMObject (FXOMObject component, List<SelectionNode> path, int step) { if (step >= path.size()) return null; SelectionNode node = new SelectionNode(component); if (node.equals(path.get(step))) { if (step == path.size() - 1) return component; List<FXOMObject> children = getChildComponents(component); if (children.isEmpty()) return null; int indexInParent = path.get(step + 1).indexInParent; if (indexInParent >= 0 && indexInParent < children.size()) { return getSelectedComponent(children.get(indexInParent), path, step + 1); } } return null; }