Capturing anomalies in data is one of the most important problems in modern data analysis. In recent years, scientists have developed many interesting approaches. One of the leading is the Isolation Forest method, which is based on searching a forest of binary trees. This method is extremely effective, especially in the case of relatively small databases. Despite of that, a lot of work has been done for years to improve it. For instance, variants based on rotation or fuzzy sets were developed. In this paper, we propose a very effective method of building search trees based on grouping data using the K-Medoids method. The results of the conducted experiments suggest a significant improvement in the quality of the method in relation to the original Isolation Forest.