private static Tuple<Match, Direction> IsFit(INode root, Shred shred, Side side)
{
Side query;
Match match;
if (side.Orientation != shred.Orientation)
{
query = new Side(shred, Enumeration.Opposite(side.Direction), shred.Orientation);
match = Match.Inverted;
}
else
{
query = side;
match = Match.NonInverted;
}
// If Directions match AND The Availablility then return match, otherwise impossible
if (query.Direction == Direction.FromLeft && root.LeftEdge() == shred.LeftEdge())
{
return new Tuple<Match, Direction>(match, Direction.FromLeft);
}
if (query.Direction == Direction.FromRight && root.RightEdge() == shred.RightEdge())
{
return new Tuple<Match, Direction>(match, Direction.FromRight);
}
return new Tuple<Match, Direction>(Match.Impossible, Direction.FromLeft);
}