Swipe screen until element found - Need function / logic

I am trying to swipe screens until element found. Can someone help here ?

Code looks like below…

Launch App

while(!element.isDisplayed()){
driver.swipe(startX1, startY1, endX1, endY1, 3000);
if(element.isDisplayed){
element.click();
break;
}
}

@santota - Is there any alternative for ScrollTo() and ScrollToExact()