@SuppressWarnings("unchecked")
	public static <T> T getAncestorOfType(Component component, Class<T> type) {
		if (component == null) {
			return null;
		}
		Container parent = component.getParent();
		while (parent != null && !type.isAssignableFrom(parent.getClass())) {
			parent = parent.getParent();
		}
		return (T) parent;
	}