private function initRelations() {
    if ($this->relations == null) {
      $this->relations = [];
      $this->relations['all'] = array_values($this->getRelationDescriptions());
      $this->relations['parent'] = [];
      $this->relations['child'] = [];
      $this->relations['undefined'] = [];
      $this->relations['nm'] = [];

      foreach ($this->relations['all'] as $relation) {
        $hierarchyType = $relation->getHierarchyType();
        $hierarchyKey = $hierarchyType == 'parent' || $hierarchyType == 'child' ?
                $hierarchyType : 'undefined';
        $this->relations[$hierarchyKey][] = $relation;

        // also store relations to many to many objects, because
        // they would be invisible otherwise
        if ($relation instanceof RDBManyToManyRelationDescription) {
          $nmRelation = $relation->getThisEndRelation();
          $this->relations['nm'][$nmRelation->getOtherRole()] = $nmRelation;
        }
      }
    }
  }