The outcome and duration of lawsuits impact people and organizations worldwide. Nowadays, judicial data is recorded in digital systems with detailed information. In this scenario, machine learning and process mining techniques can enhance the analysis of lawsuits in multiple aspects. One challenge in dealing with such data is that lawsuit prosecution movements can occur in almost any order, leading to the discovery of unstructured models. Clustering in process mining has been successfully used in some scenarios, but this context imposes new challenges. We propose an approach for analyzing legal processes based on hierarchical attributes and two-step clustering. The lawsuit’s procedural movements are first mapped to the desired granularity level, which requires an available tree structure. Next, a density-based clustering algorithm is applied to remove outliers and identify relatively homogeneous clusters of traces. Then, an agglomerative approach is applied on the centroids of the identified clusters to detect groups of clusters for analysis. We employed our approach to real data regarding Brazilian lawsuits from the Superior Court of Justice. As a result, we recognized homogeneous groups of clusters that exhibited similar characteristics. In addition to our approach, we disseminate the complete dataset of Brazilian lawsuits.