Move pathM from Tree to RTree and add a filtering mechanism.