seleniuem get parent parent elememt and iterate over elent code example
Example: selenium get parent element python
input_el = driver.find_element_by_name('A')
td_p_input = input_el.find_element_by_xpath('..')
input_el = driver.find_element_by_name('A')
td_p_input = input_el.find_element_by_xpath('..')