code: public static UIContext getClosestContextForId(final WComponent root, final String id,
  			final boolean visibleOnly) {
  
  		FindComponentByIdVisitor visitor = new FindComponentByIdVisitor(id) {
  			@Override
  			public VisitorResult visit(final WComponent comp) {
  				VisitorResult result = super.visit(comp);
  				if (result == VisitorResult.CONTINUE) {
  					// Save closest UIC as processing tree
  					setResult(new ComponentWithContext(comp, UIContextHolder.getCurrent()));
  				}
  				return result;
  			}
  		};
  
  		doTraverse(root, visibleOnly, visitor);
  
  		return visitor.getResult() == null ? null : visitor.getResult().getContext();
  	}
docs: Retrieves the closest context for the component with the given Id.
  
  @param root the root component to search from.
  @param id the id to search for.
  @param visibleOnly true if process visible only
  @return the closest context for the component with the given id, or null if not found.