PsiElement (List<? extends StubbedSpine> spines, int index) { if (spines.size() == 1) return spines.get(0).getStubPsi(index); for (StubbedSpine spine : spines) { int count = spine.getStubCount(); if (index < count) { return spine.getStubPsi(index); } index -= count; } return null; }