List<IState> states = new ArrayList<IState>();
if (state instanceof IWebflowState) {
states.addAll(((IWebflowState) state).getStates());
}
else if (state.getElementParent() instanceof IWebflowState) {
IWebflowState sws = (IWebflowState) state.getElementParent();
if (includeSelf) {
states.addAll(sws.getStates());
}
else {
for (IState s : sws.getStates()) {
if (!s.equals(state)) {
states.add(s);
}
}
}