Getting target IDs from promotions related to an order item
Use the java 8 stream API:

public Set&lt;String&gt; getTargetIdsFromPromotion(String itemToRefundId, RepositoryItem orderItem) {
    return getRelationships(orderItem).stream()
            .filter(this::isValidShippingType)
            .map(this::getAdjustments)
            .flatMap(Collection::stream)
            .map(this::getPromotion)
            .filter(Objects::nonNull)
            .map(p -&gt; getTargetIdsByQualifier(itemToRefundId, p))
            .filter(s -&gt; !s.isEmpty())
            .findFirst()
            .orElseGet(Collections::emptySet);
}