boolean (T target) { final PyClass currentClass = getContainingClass(target); // Stop when the current class changes and there was a result if (myLastVisitedClass != null && myLastVisitedClass != currentClass && myResult != null) { return false; } myLastVisitedClass = currentClass; final int index = ArrayUtil.indexOf(myNames, target.getName()); // Do not depend on the order in which elements appear, always try to find the first one if (index >= 0) { if (myLastResultIndex == -1 || index < myLastResultIndex || index == myLastResultIndex && PyiUtil.isOverload(myResult, myContext) && !PyiUtil.isOverload(target, myContext)) { myLastResultIndex = index; myResult = target; if (index == 0 && !PyiUtil.isOverload(myResult, myContext)) { return false; } } } return true; }