code: public ItemState findItemState(String id, Boolean isPersisted, int... states) throws IllegalPathException
     {
        List<ItemState> allStates = getAllStates();
        // search from the end for state
        for (int i = allStates.size() - 1; i >= 0; i--)
        {
           ItemState istate = allStates.get(i);
           boolean byState = false;
           if (states != null)
           {
              for (int state : states)
              {
                 if (istate.getState() == state)
                 {
                    byState = true;
                    break;
                 }
              }
           }
           else
           {
              byState = true;
           }
           if (byState && (isPersisted != null ? istate.isPersisted() == isPersisted : true)
              && istate.getData().getIdentifier().equals(id))
           {
              return istate;
           }
        }
        return null;
     }
docs: Search for an item state of item with given id and filter parameters.
  
  @param id
  - item id
  @param states
  - filter only the given list states (ORed), or all if it's null
  @param isPersisted
  - filter only persisted/not persisted, or all if it's null
  @return - filtered {@link ItemState}
  @throws IllegalPathException