protected T find(Class<T> expectedType, INode node, Set<EObject> visited) {
EObject current = node.getSemanticElement();
int startoffset = node.getOffset();
T result = null; // FIXME this should also find objects at current offset.
while (current != null && NodeModelUtils.getNode(current).getOffset() >= startoffset) {
if (expectedType.isInstance(current))
result = expectedType.cast(current);
visited.add(current);
current = current.eContainer();
}
return result;
}