code: private static void calculateHierarchy(final Map<String, SchemaNode> schemaNodes) {
  
  		try (final Tx tx = StructrApp.getInstance().tx()) {
  
  			final Set<String> alreadyCalculated = new HashSet<>();
  
  			// calc hierarchy
  			for (final SchemaNode schemaNode : schemaNodes.values()) {
  
  				final int relCount = Iterables.count(schemaNode.getProperty(SchemaNode.relatedFrom)) + Iterables.count(schemaNode.getProperty(SchemaNode.relatedTo));
  				final int level     = recursiveGetHierarchyLevel(schemaNodes, alreadyCalculated, schemaNode, 0);
  
  				schemaNode.setProperty(SchemaNode.hierarchyLevel, level);
  				schemaNode.setProperty(SchemaNode.relCount, relCount);
  			}
  
  			tx.success();
  
  		} catch (FrameworkException fex) {
  			logger.warn("", fex);
  		}
  	}
docs: ----- private methods -----