Optimise get_xpath_frequency_distribution

Rather than splitting string and then joining it again, the function now just splits once from the right and then selects the first element (thus, the parent).