// Make sure the markup stream is positioned at the correct element
String relativePath = getComponentRelativePath(component, parentWithAssociatedMarkup);
// If the component is defined in the markup
int index = markupStream.findComponentIndex(relativePath, component.getId());
if (index != -1)
{
// than position the stream at the beginning of the component
markupStream.setCurrentIndex(index);
return markupStream;