title: Navigating parent-child relation in PowerShell cmdlet
body: <p>Suppose I have objects that have a parent-child relationship like this:</p>
  
  <pre><code>public class Node
  {
     public string Name { get; set; }
     public string Type { get; set; }
     public Node Parent { get; set; }
  }
  </code></pre>
  
  <p>Now, I would like to create a cmdlet that supports syntax like this:</p>
  
  <pre><code>Get-Node | where {$_.Type -eq "SomeType" -and $_.Parent.Name -eq "SomeName" }
  </code></pre>
  
  <p>Here, the Parent property needs to somehow reference another object in the pipeline. Is something like this even possible in PowerShell? If not, what are the alternatives?</p>
  
  <p>[Edit]
  If I use the class above like this:</p>
  
  <pre><code>var root = new Node
  {
      Name = "root",
      Type = "root",
      Parent = null
  };
  var nodeA = new Node
  {
      Name = "A",
      Type = "node",
      Parent = root
  }
  WriteObject(root);
  WriteObject(nodeA);
  </code></pre>
  
  <p>And then load the module and try this command:</p>
  
  <pre><code>Get-MyNode | where {$_.Parent.Name = "root"}
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Property 'Name' cannot be found on this object; make sure it exists and is settable.
  At line:1 char:31
  + Get-MyNode | where {$_.Parent. &lt;&lt;&lt;&lt; Name = "root"}
      + CategoryInfo          : InvalidOperation: (Name:String) [], RuntimeException
      + FullyQualifiedErrorId : PropertyNotFound
  </code></pre>
  
  <p>I would like the Parent property to reference another object in the pipeline like a real Node object.</p>
  
  <p>[Edit] This error was caused by the public keyword missing from the class definition. Adding the keyword fixed the issue and made the example work.</p>