Added implementation for paths from non-leaf nodes.