An algorithm for finding a representation of a subtree distance