/** should be invoked in read action */
  private DefaultTreeModel buildModel() {
    final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
    final Ref<Integer> count = new Ref<Integer>(0);
    final FactoryMap<MemberChooserObject, ParentNode> map =
        new FactoryMap<MemberChooserObject, ParentNode>() {
          @Override
          protected ParentNode create(final MemberChooserObject key) {
            ParentNode node = null;
            DefaultMutableTreeNode parentNode = rootNode;

            if (supportsNestedContainers() && key instanceof ClassMember) {
              MemberChooserObject parentNodeDelegate = ((ClassMember) key).getParentNodeDelegate();

              if (parentNodeDelegate != null) {
                parentNode = get(parentNodeDelegate);
              }
            }
            if (isContainerNode(key)) {
              final ContainerNode containerNode = new ContainerNode(parentNode, key, count);
              node = containerNode;
              myContainerNodes.add(containerNode);
            }
            if (node == null) {
              node = new ParentNode(parentNode, key, count);
            }
            return node;
          }
        };

    for (T object : myElements) {
      final ParentNode parentNode = map.get(object.getParentNodeDelegate());
      final MemberNode elementNode = createMemberNode(count, object, parentNode);
      myNodeToParentMap.put(elementNode, parentNode);
      myElementToNodeMap.put(object, elementNode);
    }
    return new DefaultTreeModel(rootNode);
  }
 protected String getItemText(@NotNull T value) {
   return value.toString();
 }