The detection and analysis of structure and substructure in systems of galaxies is a well-known problem. Several methods of analysis exist with different ranges of applicability and giving different results. The aim of the present paper is to describe a general procedure of wide applicability that is based on a minimum number of general assumptions and gives an objective, testable, scale-independent and non-parametric estimate of the clustering pattern of a sample of observational data. The method follows the idea that the presence of a cluster in a data sample is indicated by a peak in the probability density underlying the data. There are two steps: the first is estimation of the probability density and the second is identification of the clusters. This method allows us to estimate the list of clusters and eventually the list of isolated objects. Moreover, it gives an estimate of the significance of each cluster and the membership probability of each cluster member. Estimates of the presence of possible interlopers within clusters and of the mutual overlapping of different clusters are also given. In the present work the univariate version of the method is presented and applied to several examples in order to compare the results with earlier work. A more general multivariate version of the method, following the same conceptual path, is in preparation.