public List<PssgNode> FindNodes(string nodeName, string attributeName = null, string attributeValue = null)
{
List<PssgNode> ret = new List<PssgNode>();
if (this.Name == nodeName)
{
if (attributeName != null && attributeValue != null)
{
PssgAttribute attr;
if (attributes.TryGetValue(attributeName, out attr) && attr.ToString() == attributeValue)
{
ret.Add(this);
}
}
else if (attributeName != null)
{
if (attributes.ContainsKey(attributeName) == true)
{
ret.Add(this);
}
}
else if (attributeValue != null)
{
foreach (KeyValuePair<string, PssgAttribute> pair in attributes)
{
if (pair.Value.ToString() == attributeValue)
{
ret.Add(this);
break;
}
}
}
else
{
ret.Add(this);
}
}
if (subNodes != null)
{
foreach (PssgNode subNode in subNodes)
{
ret.AddRange(subNode.FindNodes(nodeName, attributeName, attributeValue));
}
}
return ret;
}