int (@NotNull JComponent component) { if (component instanceof ComponentWithExpandableItems<?> c) { Collection<?> items = c.getExpandableItemsHandler().getExpandedItems(); Object item = items.isEmpty() ? null : items.iterator().next(); if (item instanceof Integer) return (Integer)item; } return -1; }