package d2ir

import (
	

	
)

// QueryAll is only for tests and debugging.
func ( *Map) ( string) ( []Node,  error) {
	,  := d2parser.ParseMapKey()
	if  != nil {
		return nil, 
	}

	if .Key != nil {
		,  := .EnsureField(.Key, nil, false, nil)
		if  != nil {
			return nil, 
		}
		if len() == 0 {
			return nil, nil
		}
		for ,  := range  {
			if len(.Edges) == 0 {
				 = append(, )
				return , nil
			}
			 = .Map()
			if  == nil {
				return nil, nil
			}
		}
	}

	 := NewEdgeIDs()

	for ,  := range  {
		 := &RefContext{
			Key:      ,
			ScopeMap: ,
			Edge:     .Edges[],
		}
		 := .GetEdges(, , nil)
		for ,  := range  {
			if .EdgeKey == nil {
				 = append(, )
			} else if .Map_ != nil {
				 := .Map_.GetField(.EdgeKey.IDA()...)
				if  != nil {
					 = append(, )
				}
			}
		}
	}
	return , nil
}

// Query is only for tests and debugging.
func ( *Map) ( string) (Node, error) {
	,  := .QueryAll()
	if  != nil {
		return nil, 
	}

	if len() == 0 {
		return nil, nil
	}
	if len() > 1 {
		return nil, fmt.Errorf("expected only one query result but got: %#v", )
	}
	return [0], nil
}