def scroll(driver, scroll_element=None):
    """Scrolls the current page or the Selenium WebElement if one is provided

    Args:
        driver (selenium.webdriver.): Selenium webdriver to use.
        scroll_element (selenium.webdriver.remote.webelement.WebElement): Selenium webelement to scroll.

    Examples:
        ::

            from selenium import webdriver
            from selenium_extensions.core import scroll


            driver = webdriver.Chrome()
            scroll(driver)

        ::

            from selenium import webdriver
            from selenium_extensions.core import scroll


            driver = webdriver.Chrome()
            ...
            pop_up = driver.find_element_by_class_name('ff_pop_up')
            scroll(driver, pop_up)
    """
    if scroll_element:
        driver.execute_script(
            'arguments[0].scrollTop = arguments[0].scrollHeight;',
            scroll_element)
    else:
        driver.execute_script(
            'document.body.scrollTop = document.body.scrollHeight;')
